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 ​
| Parameter | Type | Default value |
|---|---|---|
message | string | undefined |
code | "CONTEXT_NOT_FOUND" | "CONTEXT_INVALID" | "CONTEXT_NOT_FOUND" |
details | Record<string, unknown> | {} |
cause? | Error | undefined |
Returns ​
ContextError
Overrides ​
Properties ​
| Property | Modifier | Type | Description | Inherited from | Defined in |
|---|---|---|---|---|---|
code | readonly | AIDKErrorCode | Unique error code for programmatic handling | AIDKError.code | packages/shared/src/errors.ts:100 |
details | readonly | Record<string, unknown> | Additional error details | AIDKError.details | packages/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 ​
| Parameter | Type |
|---|---|
json | SerializedAIDKError |
Returns ​
Inherited from ​
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)