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.
Extends
Section titled “Extends”Error
Type Parameters
Section titled “Type Parameters”E = unknown
The type of the error value from the canister
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new CanisterError<
E>(err):CanisterError<E>
Defined in: errors/index.ts:48
Parameters
Section titled “Parameters”E
Returns
Section titled “Returns”CanisterError<E>
Overrides
Section titled “Overrides”Error.constructor
Properties
Section titled “Properties”
readonlyerr:E
Defined in: errors/index.ts:42
The raw error value from the canister
readonlycode:string
Defined in: errors/index.ts:44
The error code, extracted from the error object or variant key
details
Section titled “details”
readonlydetails:NullishType<Map<string,string>>
Defined in: errors/index.ts:46
Optional error details Map
Methods
Section titled “Methods”isApiError()
Section titled “isApiError()”
staticisApiError(error):error is ApiError
Defined in: errors/index.ts:105
Type guard to check if an error object follows the API error format.
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”error is ApiError
create()
Section titled “create()”
staticcreate(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.
Parameters
Section titled “Parameters”unknown
message?
Section titled “message?”string
Returns
Section titled “Returns”CanisterError