Mobus.Stepwise.Error (mobus_stepwise v0.2.0)

Copy Markdown View Source

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

Summary

Functions

Creates a new structured error.

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

Types

t()

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

Functions

new(type, reason, opts \\ [])

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

Creates a new structured error.

structured?(arg1)

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

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