onError fires when an element cannot complete an action. Every payload carries a stable code and a shopper-safe message. Validation failures also carry fieldErrors for inline rendering.
Payload
code union.
Example
Always handle it
Even elements that mostly driveonSubmit (cards, wallets) can fail validation, network, or tokenization. Register an onError handler on every element you mount.
Switch on code
The union is closed but new codes are added in minor releases. Keep a default branch so new codes surface cleanly.
Render message, not cause
messageis already localized and shopper-safe. Render it as-is.causecarries raw underlying exceptions for diagnostics (network stack traces, gateway errors, provider Link errors). Log it to your error tracker; do not surface it to shoppers. Its shape is not part of the public contract.
Validation errors
Forcode: 'validation_failed', fieldErrors is always populated. The same FieldError[] shape appears on onChange.errors while the shopper is typing:
onChange when the shopper corrects the input.
Retriable errors
Fornetwork, tokenization_failed, plaid_link_failed, and wallet_failed, surface a retry affordance. The shopper can attempt the action again once the transient condition clears.
Programmer errors
not_mounted fires when a method (submit(), validate(), internal getters) is invoked before mount() resolves. Treat it as a bug: log loudly in development. In production it usually means the calling code fires submit() before the element has mounted; guard the call site.
Bank
Every bankonError envelope additionally carries bankMode: 'plaid' | 'manual' | null:
'plaid'forplaid_link_failedand address-lookup submit gating.'manual'for manual-mode atom failures.nullonly oncode: 'not_mounted'(no live element to read the active mode from).
Wallet “unavailable” is not an error
When a wallet fails its device-availability probe, the element firesonChange { available: false, reason } and suppresses onReady. onError is reserved for actual failures during an active flow (for example, the shopper tapped Pay and the sheet rejected the token). Drive fallback rendering off onChange, not onError.
Shopper abandonment is not an error either
When the shopper dismisses a wallet sheet or the bank link modal without authorizing,onExit fires. onError does not. See onExit.