Skip to content

AIDK API Reference / aidk-shared / ContextError

Class: ContextError ​

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

Error thrown when context is missing or invalid.

Example ​

typescript
throw new ContextError('Context not found. Ensure you are running within Context.run()');
throw new ContextError('Invalid context: missing required field', 'CONTEXT_INVALID');

Extends ​

Constructors ​

Constructor ​

ts
new ContextError(
   message: string, 
   code: "CONTEXT_NOT_FOUND" | "CONTEXT_INVALID", 
   details: Record<string, unknown>, 
   cause?: Error): ContextError;

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

Parameters ​

ParameterTypeDefault value
messagestringundefined
code"CONTEXT_NOT_FOUND" | "CONTEXT_INVALID""CONTEXT_NOT_FOUND"
detailsRecord<string, unknown>{}
cause?Errorundefined

Returns ​

ContextError

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


notFound() ​

ts
static notFound(): ContextError;

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

Create "context not found" error with helpful message

Returns ​

ContextError


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.