# `AshHooks.Errors`
[🔗](https://github.com/baselabs/ash_hooks/blob/v3.3.0/lib/ash_hooks/errors.ex#L1)

Splode error hierarchy for ash_hooks.

Inbound authentication and configuration failures have class `:invalid`.
Custody availability failures have class `:unknown`. Unrecognized reasons
become contents-free `UnknownError` values.

# `class`

```elixir
@type class() :: %{
  :__struct__ =&gt; class_module(),
  :__exception__ =&gt; true,
  :errors =&gt; [t()],
  :class =&gt; error_class(),
  :bread_crumbs =&gt; [String.t()],
  :vars =&gt; Keyword.t(),
  :stacktrace =&gt; Splode.Stacktrace.t() | nil,
  :context =&gt; map(),
  optional(atom()) =&gt; any()
}
```

# `class_module`

```elixir
@type class_module() :: AshHooks.Errors.Unknown | AshHooks.Errors.Invalid
```

# `error_class`

```elixir
@type error_class() :: :unknown | :invalid
```

# `t`

```elixir
@type t() :: %{
  :__struct__ =&gt; module(),
  :__exception__ =&gt; true,
  :class =&gt; error_class(),
  :bread_crumbs =&gt; [String.t()],
  :vars =&gt; Keyword.t(),
  :stacktrace =&gt; Splode.Stacktrace.t() | nil,
  :context =&gt; map(),
  optional(atom()) =&gt; any()
}
```

# `from_reason`

```elixir
@spec from_reason(term(), Keyword.t()) :: struct()
```

Maps a provider callback's reason (the `{:error, reason}` shape the
behavior returns) to its Splode error. Known provider atoms pass `opts`
through to `exception/1`; classified package errors pass through unchanged.

Unmapped reasons become a contents-free `UnknownError`; backend terms are
never included in that error.

# `splode_error?`

# `traverse_errors`

```elixir
@spec traverse_errors(term(), (struct() -&gt; term())) :: map()
```

Calls the function for each leaf error and returns a nested map grouped
by error path. See `Splode.traverse_errors/2` for the traversal contract.

# `unwrap!`

```elixir
@spec unwrap!(term(), keyword() | nil) :: term()
```

Returns the value from `{:ok, value}` or `:ok`. Raises a converted error for
`{:error, error}` or `:error`, and `ArgumentError` for other result shapes.

Accepts `:error_opts` for error conversion and `:unknown_error_opts` when
the result is `:error`. See `Splode` for the error-conversion contract.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
