Skip to main content
zerotal

Documentation


Documentation / @zerotal/core / index / abort

Function: abort()

Call Signature

abort(message): never

Defined in: helpers/response.ts:397

Throw an HTTP error to end the request. Accepts a message (defaults to 500), an explicit status plus message, or a ZerotalError subclass to instantiate.

Parameters

message

string

Returns

never

Throws

(or the given ZerotalError subclass) — always; the return type is never.

Example

abort('Something went wrong');           // 500
abort(403, 'Forbidden');                 // explicit status
abort(NotFoundError);                    // throw a specific error class

Call Signature

abort(status, message): never

Defined in: helpers/response.ts:398

Throw an HTTP error to end the request. Accepts a message (defaults to 500), an explicit status plus message, or a ZerotalError subclass to instantiate.

Parameters

status

number

message

string

Returns

never

Throws

(or the given ZerotalError subclass) — always; the return type is never.

Example

abort('Something went wrong');           // 500
abort(403, 'Forbidden');                 // explicit status
abort(NotFoundError);                    // throw a specific error class

Call Signature

abort(ErrorClass): never

Defined in: helpers/response.ts:399

Throw an HTTP error to end the request. Accepts a message (defaults to 500), an explicit status plus message, or a ZerotalError subclass to instantiate.

Parameters

ErrorClass

() => ZerotalError

Returns

never

Throws

(or the given ZerotalError subclass) — always; the return type is never.

Example

abort('Something went wrong');           // 500
abort(403, 'Forbidden');                 // explicit status
abort(NotFoundError);                    // throw a specific error class