Skip to content

AIDK API Reference / aidk-shared / TransportError

Class: TransportError ​

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

Error thrown for network/transport failures.

Example ​

typescript
throw new TransportError('timeout', 'Request timed out after 30000ms');
throw new TransportError('connection', 'SSE connection error');
throw new TransportError('response', 'No response body');

Extends ​

Constructors ​

Constructor ​

ts
new TransportError(
   transportCode: "timeout" | "connection" | "response" | "parse", 
   message: string, 
   options: {
  method?: string;
  statusCode?: number;
  url?: string;
}, 
   cause?: Error): TransportError;

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

Parameters ​

ParameterType
transportCode"timeout" | "connection" | "response" | "parse"
messagestring
options{ method?: string; statusCode?: number; url?: string; }
options.method?string
options.statusCode?number
options.url?string
cause?Error

Returns ​

TransportError

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
statusCode?readonlynumberHTTP status code if applicable-packages/shared/src/errors.ts:449
transportCodereadonly"timeout" | "connection" | "response" | "parse"Type of transport error-packages/shared/src/errors.ts:446

Methods ​

connection() ​

ts
static connection(
   message: string, 
   url?: string, 
   cause?: Error): TransportError;

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

Create a connection error

Parameters ​

ParameterType
messagestring
url?string
cause?Error

Returns ​

TransportError


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


http() ​

ts
static http(
   statusCode: number, 
   url: string, 
   message?: string): TransportError;

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

Create an HTTP error (non-2xx response)

Parameters ​

ParameterType
statusCodenumber
urlstring
message?string

Returns ​

TransportError


timeout() ​

ts
static timeout(timeoutMs: number, url?: string): TransportError;

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

Create a timeout error

Parameters ​

ParameterType
timeoutMsnumber
url?string

Returns ​

TransportError


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.