property ErrorHandlerOptions.respond

Lets the application write its own response for a caught error. The hook receives the normalized error after status hints, internal-error masking, and status resolution, so error.statusCode is safe to serve. Return a HandlerResult produced by ctx.response to use that response; it may resolve that result asynchronously. Return or resolve to undefined to fall through to the configured formatter unchanged.

The hook owns its returned response's status, headers, and body. It is called only for errors caught by this middleware, not responder-based terminals such as an unmatched-path 404.

Type

(
error: HttpError,
ctx: IRequestContext
) =>
HandlerResult
| undefined
| Promise<HandlerResult | undefined>

Usage

import { type ErrorHandlerOptions } from "exceptions/src/index.ts";