# `AshOnetime.Error`
[🔗](https://github.com/baselabs/ash_onetime/blob/v1.5.0/lib/ash_onetime/error.ex#L1)

Typed failure returned by AshOnetime boundary modules.

`AshOnetime.Error` is a [Splode](https://hexdocs.pm/splode) error of class `:invalid`,
so Ash recognizes it and preserves it through the action pipeline instead of wrapping it
as an unknown error. The typed `:code` therefore reaches the caller inside
`Ash.Error.Invalid{errors: [%AshOnetime.Error{code: ...}]}`, where it can drive HTTP
status mapping (`AshOnetime.Error.code/1`) — see `documentation/errors.md` for the
code→HTTP table.

# `t`

```elixir
@type t() :: %AshOnetime.Error{
  __exception__: term(),
  bread_crumbs: term(),
  class: term(),
  code: atom(),
  details: map(),
  message: String.t(),
  path: term(),
  splode: term(),
  stacktrace: term(),
  vars: term()
}
```

# `code`

```elixir
@spec code(t() | Exception.t() | term()) :: atom() | nil
```

Returns the typed `:code` from an `AshOnetime.Error`, or the single leaf
`AshOnetime.Error` inside an `Ash.Error.Invalid`/`Ash.Error.Unknown` class wrapper.

Returns `nil` for any other value (including exceptions that are not `AshOnetime.Error`
and class wrappers carrying no `AshOnetime.Error` leaf), so a caller can distinguish
"ash_onetime rejected this with a known code" from "some other error occurred" without
pattern-matching the wrapper shape.

# `exception`

```elixir
@spec exception(opts :: Keyword.t()) :: %AshOnetime.Error{
  __exception__: term(),
  bread_crumbs: term(),
  class: term(),
  code: term(),
  details: term(),
  message: term(),
  path: term(),
  splode: term(),
  stacktrace: term(),
  vars: term()
}
```

Create an `Elixir.AshOnetime.Error` without raising it.

## Keys

- :code
- :message
- :details

# `new`

```elixir
@spec new(atom(), String.t(), map()) :: t()
```

---

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