Errors
Catch the typed error classes the SDK throws at public boundaries.
What validation can’t catch is thrown, as named classes that all extend
BaseError. Narrow with instanceof against the
classes your UI treats differently, fall back to instanceof BaseError for anything else the SDK
throws, and rethrow the rest. BaseError.walk() finds a specific class anywhere in a wrapped
error’s cause chain.
The ones most apps handle:
UserRejectedRequestError: the user declined a wallet prompt.WalletNotConnectedError: a write needs a wallet and none is connected.TransactionRevertError: the chain rejected a transaction.WorkflowSignerChangedError: the connected account changed between building a workflow and executing it.StalePythPriceErrorandPriceServerError: a price was too old to use, or the price service couldn’t be reached.ConfigError: the SDK was given configuration it can’t use.ProviderConnectionError: the RPC provider couldn’t be reached. Retrying later can succeed.InvalidArgumentError: a call’s arguments can’t be used.fieldNameslists them.SubgraphCompatibilityError: a LOC read got indexed data this SDK version can’t read.ContactSupportError: a failure the SDK can’t explain. Itscodeis for support.
Problems with user input aren’t errors: they come back from validation as issues.
Sending a transaction and narrowing what comes back:
try { const hash = await sendTransaction(ctx, { transaction }); return { hash };} catch (error) { // Narrow with instanceof against the classes your UI treats // differently; fall back to a generic message for the rest. if (error instanceof UserRejectedRequestError) { return { error: 'cancelled by user' }; } if (error instanceof WalletNotConnectedError) { return { error: 'connect a wallet first' }; } if (error instanceof TransactionRevertError) { return { error: `reverted: ${error.message}` }; } if (error instanceof BaseError) { return { error: error.message }; } throw error;}Primary APIs
Classes
BaseError— Base class for the SDK’s typed errors.ConfigError— Error thrown when the SDK’s setup cannot support the requested operation.ContactSupportError— Error for a failure the SDK cannot explain, such as an unexpected error inside a validation rule.InvalidArgumentError— Error thrown when the arguments to an SDK call cannot be used, before anything is sent: a required list is empty, two options conflict, or…PriceServerError— Error thrown when the SDK cannot get a usable price from the Pyth price service (Hermes).ProviderConnectionError— Error thrown when the SDK cannot reach the RPC provider: a read, a chain or ENS lookup, or a validation rule could not finish because the…StalePythPriceError— Error thrown when the Pyth price service returns a price that is unsafe to use because its publish time is too far from now, in the past or…SubgraphCompatibilityError— Error thrown when a LOC read gets data from the subgraph that this SDK version cannot read faithfully: the index belongs to a different…TransactionRevertError— Error for a transaction the contract rejected (reverted).UserRejectedRequestError— Error for a request the user declined in their wallet, such as a transaction or signature prompt.WalletNotConnectedError— Error thrown when an operation needs a connected wallet account and none is available: no wallet client is configured, it has no account,…WorkflowSignerChangedError— Error thrown when the account signing differs from the account an operation was prepared for: the connected wallet changed after a workflow…