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.