Skip to content

Commit

Permalink
fix: add back in accidentally removed debug errors code
Browse files Browse the repository at this point in the history
this also cleans up references to `Ash.ErrorKind` which is
dead code in 3.x
  • Loading branch information
zachdaniel committed Aug 12, 2024
1 parent 151240d commit 2bd4726
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 31 deletions.
2 changes: 0 additions & 2 deletions .tool-versions

This file was deleted.

19 changes: 10 additions & 9 deletions lib/ash_authentication/errors/authentication_failed.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ defmodule AshAuthentication.Errors.AuthenticationFailed do
@moduledoc """
A generic, authentication failed error.
"""
use Ash.Error.Exception

use Splode.Error,
fields: [
caused_by: %{},
Expand All @@ -14,14 +12,17 @@ defmodule AshAuthentication.Errors.AuthenticationFailed do
],
class: :forbidden

@type t :: Exception.t()
alias AshAuthentication.Debug

def message(_), do: "Authentication failed"
@type t :: Exception.t()

defimpl Ash.ErrorKind do
@moduledoc false
def id(_), do: Ecto.UUID.generate()
def code(_), do: "authentication_failed"
def message(_), do: "Authentication failed"
@impl true
def exception(args) do
args
|> super()
|> Debug.describe()
end

@impl true
def message(_), do: "Authentication failed"
end
9 changes: 0 additions & 9 deletions lib/ash_authentication/errors/invalid_token.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,7 @@ defmodule AshAuthentication.Errors.InvalidToken do
@moduledoc """
An invalid token was presented.
"""
use Ash.Error.Exception
use Splode.Error, fields: [:type], class: :forbidden

def message(%{type: type}), do: "Invalid #{type} token"

defimpl Ash.ErrorKind do
@moduledoc false
def id(_), do: Ecto.UUID.generate()
def code(_), do: "invalid_token"
def message(%{type: nil}), do: "Invalid token"
def message(%{type: type}), do: "Invalid #{type} token"
end
end
11 changes: 0 additions & 11 deletions lib/ash_authentication/errors/missing_secret.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,9 @@ defmodule AshAuthentication.Errors.MissingSecret do
@moduledoc """
A secret is now missing.
"""
use Ash.Error.Exception
use Splode.Error, fields: [:resource], class: :forbidden

def message(%{path: path, resource: resource}) do
"Secret for `#{Enum.join(path, ".")}` on the `#{inspect(resource)}` resource is not accessible."
end

defimpl Ash.ErrorKind do
@moduledoc false
def id(_), do: Ecto.UUID.generate()
def code(_), do: "missing_secret"

def message(%{path: path, resource: resource}),
do:
"Secret for `#{Enum.join(path, ".")}` on the `#{inspect(resource)}` resource is not accessible."
end
end

0 comments on commit 2bd4726

Please sign in to comment.