View Source Ash.Error (ash v3.4.43)

Tools and utilities used by Ash to manage and conform errors

Summary

Types

@type class() :: %{
  :__struct__ => class_module(),
  :__exception__ => true,
  :errors => [t()],
  :class => error_class(),
  :bread_crumbs => [String.t()],
  :vars => Keyword.t(),
  :stacktrace => Splode.Stacktrace.t() | nil,
  :context => map(),
  optional(atom()) => any()
}
@type class_module() ::
  Ash.Error.Unknown
  | Ash.Error.Framework
  | Ash.Error.Invalid
  | Ash.Error.Forbidden
@type error_class() :: :unknown | :framework | :invalid | :forbidden
@type t() :: %{
  :__struct__ => module(),
  :__exception__ => true,
  :class => error_class(),
  :bread_crumbs => [String.t()],
  :vars => Keyword.t(),
  :stacktrace => Splode.Stacktrace.t() | nil,
  :context => map(),
  optional(atom()) => any()
}

Functions

Link to this function

error_descriptions(errors)

View Source
Link to this function

splode_error?(arg1, splode)

View Source
Link to this function

to_ash_error(value, stacktrace \\ nil, opts \\ [])

View Source
Link to this function

to_error_class(value, opts \\ [])

View Source
Link to this function

unwrap!(result, opts \\ nil)

View Source

Raises an error if the result is an error, otherwise returns the result

Alternatively, you can use the defsplode macro, which does this automatically.

Options

  • :error_opts - Options to pass to to_error/2 when converting the returned error
  • :unknown_error_opts - Options to pass to the unknown error if the function returns only :error. not necessary if your function always returns {:error, error}.

Examples

def function(arg) do

case do_something(arg) do
  :success -> :ok
  {:success, result} -> {:ok, result}
  {:error, error} -> {:error, error}
end

end

def function!!(arg) do

YourErrors.unwrap!(function(arg))

end