Skip to main content

Errors

A call fails with a DriverError. A swap the server gives up ends Canceled instead, with the server's reason.

Failed calls​

error.retryable() is true for an outage the next attempt may outlive: a chain or server that is unreachable, or a server answering 429 or 5xx. Anything else needs attention before acting again.

A refusal from the server carries the server's code, in DriverError::Server(ClientError::Api { code, .. }). Branch on the code, never on the HTTP status or the message.

Server codeStatusMeaning
BadRequest400A field is missing or malformed. The message names it.
PolicyError400The request is outside the server's policy: chain, asset or amount. Quote again.
Forbidden403The request signature is missing, stale or invalid.
SwapNotFound404No swap with this id.
SwapAlreadyExists409The swap id is taken.
TransitionRejected409The swap is past the message. The driver treats it as delivered.
InsufficientLiquidity409SwapOut: the server cannot fund receive_amount. Retry later or lower the amount.
QuoteExpired410The quote is past expires_at. Quote again.
PayloadTooLarge413The body is over the server's limit.
TooManyConnections429Too many WebSocket subscriptions for this wallet.
Internal500A fault on the server.
NotImplemented501A swap type the server does not serve.
Unavailable503A backend the server needs is down. Retry later.

The driver's own errors:

ErrorMeaning
ChainA chain read or broadcast failed. Retryable.
Server(ClientError::Transport)The server did not answer within server_timeout. Retryable.
StoreThe store failed.
RecordVersionA record of a version this SDK does not drive; see records across releases.
WalletKey derivation failed, or the client has no wallet.
DestinationThe destinations hook failed.
RefusedThe server's copy of the swap does not match your request.
UnsignedRestore: the server holds no signed request for the swap.
BadSignatureRestore: the server's copy of the request does not verify against this wallet.
ChainNotConfiguredThe swap is on a chain with no chain client.
InvalidChainConfigA per-chain knob is out of range.
UnknownThe swap is not in the store.
QuoteExpiredThe quote passed expires_at before the swap was created.
WrongSwapTypeA quote or call for the other flow.
NotQuotableThe server offers no quote for these ends.
AmountOutOfRangeThe amount is outside the server's limits.
Tx, Utxo, MissingFieldA fault in the SDK.

Canceled swaps​

A swap the server gave up ends Canceled with the reason ServerCanceled. Its error_type says why, and cancel_message is the server's text, for display:

error_typeFlowMeaning
UserCanceledbothA cancel the driver sent, on request or past expires_at.
TimeoutbothA server deadline passed.
TxValidationFailedSwapInTwo or more deposits paid the exact amount.
PayInvoiceFailedSwapInPaying the invoice failed for good.
TxBroadcastFailedSwapOutThe server never broadcast its output.

The other reasons a swap ends Canceled are in Swaps.