# `Mobus.Stepwise.Error`
[🔗](https://github.com/fosferon/mobus_stepwise/blob/main/lib/mobus/stepwise/error.ex#L1)

Structured error metadata for capability and engine errors.

Provides richer error classification than raw reason terms,
enabling orchestrators to make policy decisions (retry, skip,
escalate) without string-parsing error reasons.

## Usage

Capabilities can return structured errors:

    {:error, %Mobus.Stepwise.Error{
      type: :validation,
      source: :capability,
      reason: "email already exists",
      recoverable?: true,
      retryable?: false
    }}

The engine passes these through transparently. Orchestrators
can pattern-match on the struct:

    case Result.error_reason(result) do
      %Error{retryable?: true} -> schedule_retry(...)
      %Error{recoverable?: false} -> escalate(...)
      raw_reason -> handle_legacy(raw_reason)
    end

# `t`

```elixir
@type t() :: %Mobus.Stepwise.Error{
  detail: term() | nil,
  reason: term(),
  recoverable?: boolean(),
  retryable?: boolean(),
  source: atom() | nil,
  type: atom()
}
```

# `new`

```elixir
@spec new(atom(), term(), keyword()) :: t()
```

Creates a new structured error.

# `structured?`

```elixir
@spec structured?(term()) :: boolean()
```

Returns `true` if the value is a `%Mobus.Stepwise.Error{}` struct.

---

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