Skip to main content
Version: 1.15.0

Class: CCIPError

Defined in: errors/CCIPError.ts:28

Base error class for CCIP SDK.

Example​

TypeScript
if (CCIPError.isCCIPError(error) && error.isTransient) {
await sleep(error.retryAfterMs ?? 5000)
}

Extends​

  • Error

Extended by​

Constructors​

Constructor​

new CCIPError(code: CCIPErrorCode, message: string, options?: CCIPErrorOptions): CCIPError

Defined in: errors/CCIPError.ts:51

Creates a CCIPError with code, message, and options.

Parameters​

ParameterTypeDescription
codeCCIPErrorCodeMachine-readable error code
messagestringHuman-readable error message
options?CCIPErrorOptionsAdditional error options (cause, context, isTransient, etc.)

Returns​

CCIPError

Overrides​

Error.constructor

Properties​

_isCCIPError​

readonly _isCCIPError: true

Defined in: errors/CCIPError.ts:30

Brand for cross-module identification (dual package hazard).


code​

readonly code: CCIPErrorCode

Defined in: errors/CCIPError.ts:32

Machine-readable error code.


context​

readonly context: Record<string, unknown>

Defined in: errors/CCIPError.ts:34

Structured context (IDs, addresses).


isTransient​

readonly isTransient: boolean

Defined in: errors/CCIPError.ts:36

True if retry may succeed.


name​

readonly name: string = 'CCIPError'

Defined in: errors/CCIPError.ts:42

Overrides​

Error.name


recovery?​

readonly optional recovery?: string

Defined in: errors/CCIPError.ts:40

Recovery suggestion.


retryAfterMs?​

readonly optional retryAfterMs?: number

Defined in: errors/CCIPError.ts:38

Retry delay in ms.

Methods​

toJSON()​

toJSON(): Record<string, unknown>

Defined in: errors/CCIPError.ts:105

Serializes the error for logging.

Use this instead of JSON.stringify(error) directly, as Error properties are non-enumerable and would be lost.

Returns​

Record<string, unknown>

An object containing all error properties


from()​

static from(error: unknown, code?: CCIPErrorCode): CCIPError

Defined in: errors/CCIPError.ts:89

Wraps an unknown caught value in a CCIPError.

Useful for normalizing errors in catch blocks.

Parameters​

ParameterTypeDescription
errorunknownThe error to wrap
code?CCIPErrorCodeOptional error code (defaults to 'UNKNOWN')

Returns​

CCIPError

A CCIPError wrapping the original error


isCCIPError()​

static isCCIPError(error: unknown): error is CCIPError

Defined in: errors/CCIPError.ts:73

Type guard for CCIPError.

Prefer this over instanceof to handle the dual package hazard when multiple versions of the SDK may be present.

Parameters​

ParameterTypeDescription
errorunknownThe error to check

Returns​

error is CCIPError

True if the error is a CCIPError instance