Class PendleContractError<ErrorType>

Error class that wrap all error from Pendle contract.

Remarks

As there are a lot of errors that can be returned from the Pendle contract, we only provide one class to wrap all the error. The error name can be access via PendleContractError#errorName, and the arguments can be access via PendleContractError#args.

As we only use one class to wrap all the errors, initially PendleContractError#args will not have a concrete type (you can think of any[]). To narrow down which error, with the correct type of args, use PendleContractError#isType.

Example

try {
// ....
} catch (e) {
if (e instanceof PendleContractError) {
if (e.isType('MarketInsufficientPtForTrade')) {
// e.args will now have type [BN, BN]
} else if (e.isType('ChainNotSupported')) {
// e.args will now have type [BN]
}
// ...
}
}

See

Type Parameters

Hierarchy (view full)

Constructors

Properties

cause?: unknown

Remarks

Below ES2022, Error has no cause. Adding it here as fallback so it is still accessible.

errorName: ErrorType
ethersJsError: Error

the error thrown by Ethers.js that causes this Error.

message: string
name: string
stack?: string
errorMessageHandler: PendleContractErrorMessageHandler = defaultPendleContractErrorMessageHandler

The message handlers for the given error.

Remarks

The handlers are used to generate a descriptive error message (to send to the super). This can be overridden to have different error messages (for example, to have more user-friendly messages).

errorsInterface: Interface = ...
factory: ContractErrorFactory<PendleSdkError, ((data, ethersJsError) => undefined | PendleContractError<keyof PendleContractErrorMessageHandler>)> = ...

Type declaration

prepareStackTrace?: ((err, stackTraces) => any)

Optional override for formatting stack traces

Type declaration

stackTraceLimit: number

Methods

  • Create .stack property on a target object

    Parameters

    • targetObject: object
    • Optional constructorOpt: Function

    Returns void

Generated using TypeDoc