Skip to content

CanisterError

Defined in: errors/index.ts:40

Error thrown when the canister returns an Err result. The err property contains the typed error value from the canister.

It also supports accessing code, message, and details directly if the error object follows the common API error format or is a variant.

  • Error

E = unknown

The type of the error value from the canister

new CanisterError<E>(err): CanisterError<E>

Defined in: errors/index.ts:48

E

CanisterError<E>

Error.constructor

readonly err: E

Defined in: errors/index.ts:42

The raw error value from the canister


readonly code: string

Defined in: errors/index.ts:44

The error code, extracted from the error object or variant key


readonly details: NullishType<Map<string, string>>

Defined in: errors/index.ts:46

Optional error details Map

static isApiError(error): error is ApiError

Defined in: errors/index.ts:105

Type guard to check if an error object follows the API error format.

unknown

error is ApiError


static create(error, message?): CanisterError

Defined in: errors/index.ts:119

Factory method to create a CanisterError from any error. If the input is already a CanisterError, it returns it. If it’s an API error shape, it wraps it. Otherwise, it creates a new CanisterError with an “UNKNOWN_ERROR” code.

unknown

string

CanisterError