Skip to main content
After you read this page, you can catch each SDK error by its class, read its fields, and show the right message. Every class below extends Error and sets name to the class name. Use instanceof with the class that you import from @anafi-cc/anafi-sdk. A check failure, a wrong reply shape, or a refused input that has no class throws a plain Error whose message says what failed; each method entry lists them.

Class tree

Catch the most specific class first.

BackendRequestError

A request to the Anafi API that did not succeed. status is null when the connection failed or the request timed out; cause then holds the failure. The default message is "<route> failed: <status> <body>". For the error bodies of each route, see API errors.

DslStageRefusedError

The engine refused to stage a document, and the sealed reason opened. The message is "the engine refused the document: <refusal>". status is the HTTP status of the refusal, normally 422. Thrown by stageDsl, armSafe, commitDslFromSafe and stageErc20AllowDsl. Show refusal to the author of the document, fix the document, and stage again.

NotificationEmailNotVerifiedError

The engine refused a stage because the document names a global.notification_email that is not the verified inbox of the account. Verify the inbox (notification email), or remove the field and the notify actions, then stage again.

DslStaleParentError

The engine refused to attest because the registry no longer holds the parent that you built the document on. Another commit landed since you read it. The message is "the engine refused the document: <reason>". The HTTP status was 409. It does not extend BackendRequestError. Read the document at current (for example with recover), apply your change to it, and stage again with parent: current.

Erc20AllowNotLiveError

The permission of an ERC20Allow account cannot serve the document, and a commit cannot fix it. Thrown by stageErc20AllowDsl and the subscription setup.

Erc20AllowSpentTokenUnnamedError

A send or a swap input of the document names no token that the SDK can read, or the document cannot be read. A trigger.value under a trigger with no token range names no token. Write a literal amount, or give the trigger a token range.

Erc20AllowNativeSwapTokenError

A swap of rule sells or buys the native coin, which the ERC20Allow adapter cannot pull and does not pay out. Use an ERC-20 on that side.

Erc20AllowSwapsNotServedError

rule swaps, and the ERC20Allow adapter answers no swap executor (the zero address, or a revert). The engine cannot run the swap. Remove the swap from the document.

Erc20AllowSwapSupportUnreadError

The read of swapExecutor() failed for a reason other than a revert, so the SDK does not know whether the adapter runs swaps. Retry.

Erc20AllowStagedDocumentMismatchError

A staged value does not match its own text: commitment is not keccak256(salt ‖ yaml), or tokens is not tokens(D) of yaml in order. This happens when the staged value was changed or came from somewhere else. Stage the document again.

OwnerRequestCancelledError

Your wallet client throws it when it sees the signal of a payment method abort before it asks the wallet. No request reached the wallet. The payment methods catch it and answer stopped_before_request with reason cancelled. You throw this class; the SDK does not throw it to you.

GenerateDslError

Thrown by generateDsl. See rule builders.

HTTP error mapping

Timeouts: 180 seconds for each POST above except generateDsl (45 seconds); 10 seconds for fees, sponsorship and activity; 15 seconds for discovery. Chain reads and wallet requests do not go through this table. A failed chain read rejects with the viem error (see reads). A wallet rejection rejects with the wallet error.