Skip to main content
The SDK draws a line between two kinds of failure.
  • Flow-level failures are expected outcomes. The on-chain flows (coinlist.superstate.execute, coinlist.tokenSale.execute, coinlist.superstate.authorizeWallet, coinlist.ondo.prepareBuy, coinlist.ondo.prepareSell, coinlist.ondo.executeSwap) return a tagged result rather than throwing, so you handle them with a branch, not a catch.
  • Thrown errors are for genuinely exceptional conditions, such as calling an authenticated method without a session.

Wallet errors

WalletError is the shared vocabulary for anything the user’s wallet does. It appears as the cause on any step that asked the wallet to sign or send. If you drive a wallet yourself, classifyWalletError(error, { hash }) turns a raw thrown wallet error into a typed WalletError. Pass hash when you are awaiting a receipt so a timeout can be reported against the right transaction.

Superstate swap errors

coinlist.superstate.execute returns SwapExecutionError, tagged by step. The wallet is only asked to sign after all read-only checks pass, so a user never signs a transaction the swap would revert on for a reason the SDK could have caught first.

Token sale errors

coinlist.tokenSale.execute returns TokenSaleExecutionError.
The participation step is the one to handle carefully. The user’s funds are already approved on-chain, but the participation was not recorded. Keep approvalTxHash, surface it to the user, and reconcile rather than asking them to approve a second time.

Allowance resets

The allowance-reset steps only occur when the wallet already holds a non-zero allowance that must be set to zero first. USDT-style tokens reject a non-zero to non-zero approve(), so the SDK resets before re-approving. This means those users see two wallet prompts instead of one, which is worth reflecting in your loading copy.

Ondo swap errors

Placing an Ondo order is two calls, so it has two error types. coinlist.ondo.prepareBuy and coinlist.ondo.prepareSell both return OndoSwapPreparationError - every arm names a remedy rather than a direction, and an unsupported chain, a refused approval and a build that would not complete are fixed the same way whichever token was being approved. coinlist.ondo.executeSwap returns OndoSwapExecutionError, for either direction.
quote-expired is a refusal to broadcast rather than a failure of a broadcast. It would revert on-chain and cost the user gas, and it is fixed by building a fresh transaction rather than by retrying the same one.
spender-mismatch was removed in v0.12.0. The spender now comes off the offer’s swapContracts, and the backend compares the built transaction’s destination to the contract it serves there, so a third comparison would check one source against itself. A wrong spender still surfaces, as insufficient-allowance.

Wallet authorization errors

coinlist.superstate.authorizeWallet returns WalletAuthorizationError. See Superstate Swap for the full table and the progress phases.

Wallet connection errors

ConnectWalletError carries a code, a message, and a retryable flag. Respect retryable when deciding whether to offer a retry button.

OAuth errors

useCompleteOAuth fails with a CompleteOAuthFailureReason, which is either complete_request_failed or one of the client-side reasons below.

KYC token errors

useKycToken fails with not-authenticated when there is no session, or generic-error for everything else.

Thrown errors

Reading an API error code

HttpError is what every API call rejects with when the backend refuses a request, so it is the only way to catch a 4xx by type. Catching by type is half of it - telling two 422s apart takes the code inside the body, which is what apiErrorCode reads. Below, insufficient_allowance is the code POST /v1/ondo/swap/buy and POST /v1/ondo/swap/sell return when the wallet has not approved the swap contract for the amount. prepareBuy and prepareSell already absorb it into their insufficient-allowance step, so you only write this when you call a builder yourself.

Next steps

Allowlist a wallet

Wallet authorization, its phases, and its error steps.

Package overview

Entry points and what each one exports.