Normalized payment failure surfaced to the caller (agent, LLM, or human).
Every payment error path collapses to a small closed set of reasons so the
surface can render a clear sentence and decide whether a retry is worth it,
instead of leaking a raw HTTP tuple or an inspect/1 dump. from/1 maps any
internal error term (quote miss, terminal intent status, HTTP error, spend
gate denial, validation error) onto a %Failure{}.
The struct carries:
:reason-- one of the closed reason atoms below.:message-- a human sentence safe to show a user.:retryable?-- whether an immediate retry could plausibly succeed.:detail-- the original error term, kept for logs and debugging.
String.Chars returns the message; Inspect renders reason: message, so a
generic surface that to_strings or inspects the error still shows prose.
Summary
Functions
Normalize any payment error term into a %Failure{}. Idempotent: passing a
%Failure{} returns it unchanged.
Types
@type reason() ::
:no_liquidity
| :not_filled
| :expired
| :refunded
| :settlement_failed
| :timeout
| :over_budget
| :requires_confirmation
| :insufficient_balance
| :route_unsupported
| :slippage
| :delivery_below_floor
| :rejected
| :stealth_keys_required
| :stealth_unsupported
| :sign_failed
| :method_mismatch
| :invalid_request
| :config_error
| :checkpoint_required
| :policy_required
| :stranded
| :network
| :unknown