Skip to content

AIDK API Reference / aidk-shared / AbortError

Class: AbortError ​

Defined in: packages/shared/src/errors.ts:187

Error thrown when an operation is aborted or cancelled.

Example ​

typescript
throw new AbortError('User cancelled the operation');
throw new AbortError('Operation timed out', 'ABORT_TIMEOUT', { timeoutMs: 30000 });

Extends ​

Constructors ​

Constructor ​

ts
new AbortError(
   message: string, 
   code: "ABORT_CANCELLED" | "ABORT_TIMEOUT" | "ABORT_SIGNAL", 
   details: Record<string, unknown>, 
   cause?: Error): AbortError;

Defined in: packages/shared/src/errors.ts:188

Parameters ​

ParameterTypeDefault value
messagestring"Operation aborted"
code"ABORT_CANCELLED" | "ABORT_TIMEOUT" | "ABORT_SIGNAL""ABORT_CANCELLED"
detailsRecord<string, unknown>{}
cause?Errorundefined

Returns ​

AbortError

Overrides ​

AIDKError.constructor

Properties ​

PropertyModifierTypeDescriptionInherited fromDefined in
codereadonlyAIDKErrorCodeUnique error code for programmatic handlingAIDKError.codepackages/shared/src/errors.ts:100
detailsreadonlyRecord<string, unknown>Additional error detailsAIDKError.detailspackages/shared/src/errors.ts:103

Methods ​

fromJSON() ​

ts
static fromJSON(json: SerializedAIDKError): AIDKError;

Defined in: packages/shared/src/errors.ts:163

Create error from serialized format

Parameters ​

ParameterType
jsonSerializedAIDKError

Returns ​

AIDKError

Inherited from ​

AIDKError.fromJSON


fromSignal() ​

ts
static fromSignal(signal: AbortSignal): AbortError;

Defined in: packages/shared/src/errors.ts:201

Create from an AbortSignal's reason

Parameters ​

ParameterType
signalAbortSignal

Returns ​

AbortError


timeout() ​

ts
static timeout(timeoutMs: number): AbortError;

Defined in: packages/shared/src/errors.ts:219

Create a timeout abort error

Parameters ​

ParameterType
timeoutMsnumber

Returns ​

AbortError


toJSON() ​

ts
toJSON(): SerializedAIDKError;

Defined in: packages/shared/src/errors.ts:131

Serialize error for transport (JSON-safe)

Returns ​

SerializedAIDKError

Inherited from ​

AIDKError.toJSON

Released under the MIT License.