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.
Example
Section titled “Example”throw new GatewayError(429, "rate_limited", "Too many requests", { "retry-after": "60",});// Produces: { "error": "rate_limited", "message": "Too many requests", "statusCode": 429 }Extends
Section titled “Extends”Error
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new GatewayError(
statusCode,code,message,headers?):GatewayError
Defined in: src/core/errors.ts:33
Parameters
Section titled “Parameters”statusCode
Section titled “statusCode”number
string
message
Section titled “message”string
headers?
Section titled “headers?”Record<string, string>
Returns
Section titled “Returns”GatewayError
Overrides
Section titled “Overrides”Error.constructor
Properties
Section titled “Properties”cause?
Section titled “cause?”
optionalcause:unknown
Defined in: docs/node_modules/typescript/lib/lib.es2022.error.d.ts:26
Inherited from
Section titled “Inherited from”Error.cause
readonlycode:string
Defined in: src/core/errors.ts:29
headers?
Section titled “headers?”
readonlyoptionalheaders:Record<string,string>
Defined in: src/core/errors.ts:31
Optional headers to include in the error response (e.g. rate-limit headers)
message
Section titled “message”message:
string
Defined in: docs/node_modules/typescript/lib/lib.es5.d.ts:1077
Inherited from
Section titled “Inherited from”Error.message
name:
string
Defined in: docs/node_modules/typescript/lib/lib.es5.d.ts:1076
Inherited from
Section titled “Inherited from”Error.name
stack?
Section titled “stack?”
optionalstack:string
Defined in: docs/node_modules/typescript/lib/lib.es5.d.ts:1078
Inherited from
Section titled “Inherited from”Error.stack
statusCode
Section titled “statusCode”
readonlystatusCode:number
Defined in: src/core/errors.ts:28