Skip to content

Commit

Permalink
improvement: Implement AshGraphql.Error for AshAuthentication error…
Browse files Browse the repository at this point in the history
…s. (#237)
  • Loading branch information
jimsynz authored Nov 14, 2024
1 parent 4559267 commit 32d1c1b
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions lib/error.ex
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,27 @@ defimpl AshGraphql.Error, for: Ash.Error.Invalid.InvalidPrimaryKey do
}
end
end

defimpl AshGraphql.Error, for: AshAuthentication.Errors.AuthenticationFailed do
def to_error(_error) do
%{
message: "Authentication failed",
short_message: "Authentication failed",
fields: [],
code: "authentication_failed",
vars: %{}
}
end
end

defimpl AshGraphql.Error, for: AshAuthentication.Errors.InvalidToken do
def to_error(_error) do
%{
message: "An invalid token was presented",
short_message: "Invalid token",
fields: [],
code: "invalid_token",
vars: %{}
}
end
end

0 comments on commit 32d1c1b

Please sign in to comment.