diff --git a/lib/ash/error/forbidden/forbidden_field.ex b/lib/ash/error/forbidden/forbidden_field.ex new file mode 100644 index 00000000..77d1e70d --- /dev/null +++ b/lib/ash/error/forbidden/forbidden_field.ex @@ -0,0 +1,18 @@ +defmodule Ash.Error.Forbidden.ForbiddenField do + @moduledoc "Raised in cases where access to a specific field was prevented" + + require Logger + use Ash.Error.Exception + + def_ash_error([:resource, :field], class: :forbidden) + + defimpl Ash.ErrorKind do + def id(_), do: Ecto.UUID.generate() + + def message(error) do + "Forbidden: cannot access #{error.field} on #{inspect(error.resource)}" + end + + def code(_), do: "forbidden_field" + end +end