Skip to content

GatewayError

Defined in: src/core/errors.ts:27

Structured gateway error with HTTP status code, machine-readable code, and optional response headers (e.g. Retry-After, X-RateLimit-*).

Throw this from policies or handlers to produce a structured JSON error response. The gateway error handler catches it automatically.

throw new GatewayError(429, "rate_limited", "Too many requests", {
"retry-after": "60",
});
// Produces: { "error": "rate_limited", "message": "Too many requests", "statusCode": 429 }
  • Error

new GatewayError(statusCode, code, message, headers?): GatewayError

Defined in: src/core/errors.ts:33

number

string

string

Record<string, string>

GatewayError

Error.constructor

optional cause: unknown

Defined in: docs/node_modules/typescript/lib/lib.es2022.error.d.ts:26

Error.cause


readonly code: string

Defined in: src/core/errors.ts:29


readonly optional headers: Record<string, string>

Defined in: src/core/errors.ts:31

Optional headers to include in the error response (e.g. rate-limit headers)


message: string

Defined in: docs/node_modules/typescript/lib/lib.es5.d.ts:1077

Error.message


name: string

Defined in: docs/node_modules/typescript/lib/lib.es5.d.ts:1076

Error.name


optional stack: string

Defined in: docs/node_modules/typescript/lib/lib.es5.d.ts:1078

Error.stack


readonly statusCode: number

Defined in: src/core/errors.ts:28