Skip to content

API ReferenceErrorsClass

TransactionRevertError

Error for a transaction the contract rejected (reverted). type names the contract error that caused it, and message is a readable explanation you can show the user.

Inside a WalletOperationWorkflow a revert does not throw: the step is marked Failed, and its validationErrorResponse carries the reason.

Extends

Constructors

Constructor

new TransactionRevertError(
type,
cause?,
message?
): TransactionRevertError;

Parameters

ParameterTypeDescription
typeRevertErrorTypeThe contract error that caused the revert, decoded from the revert data. It is RevertErrorType.Unknown when the SDK could not decode the revert; the raw error is then this error’s cause.
cause?unknown-
message?string-

Returns

TransactionRevertError

Overrides

BaseError.constructor

Properties

type

type: RevertErrorType;

The contract error that caused the revert, decoded from the revert data. It is RevertErrorType.Unknown when the SDK could not decode the revert; the raw error is then this error’s cause.

Methods

walk()

walk<T>(errorType): T | undefined;

Finds an error of the given class in this error’s cause chain. The search starts with this error itself, then follows each cause in turn.

Type Parameters

Type ParameterDescription
T extends ErrorThe error class being searched for.

Parameters

ParameterTypeDescription
errorType(…args) => TThe error class to find, such as UserRejectedRequestError.

Returns

T | undefined

The first error in the chain that is an instance of errorType, or undefined if there is none.

Example

const rejected = error.walk(UserRejectedRequestError);
if (rejected) return; // the user declined in their wallet

Inherited from

BaseError.walk