/** * HTTP Error Boundary Middleware * * Unified error catch → serialize → respond pipeline for HTTP boundaries. * Implements RFC 9457 (Problem Details for HTTP APIs) compliant error responses. * * @module errors/middleware/http-error-boundary * @see https://datatracker.ietf.org/doc/html/rfc9457 */ import type { Handler, HandlerContext, HandlerResult } from "../../types/server.js"; /** * Wrap a handler with error boundary that catches all errors and converts them * to RFC 9457 Problem Details responses. * * Behavior: * - VeryfrontError → toRFC9457() with application/problem+json * - Plain Error → wrap as unknown-error slug, then serialize * - Dev mode (isLocalProject): include stack field in response * - Production: omit stack, omit detail for 5xx errors * * @example * ```typescript * const handler: Handler = { * metadata: { name: "api-handler", priority: HandlerPriority.MEDIUM }, * handle: httpErrorBoundary(async (req, ctx) => { * // Your handler code that may throw * return { response: new Response("OK") }; * }), * }; * ``` */ export declare function httpErrorBoundary(handlerFn: (req: Request, ctx: HandlerContext) => Promise): (req: Request, ctx: HandlerContext) => Promise; /** * Wrap a complete Handler object with error boundary * * @example * ```typescript * export const myHandler = wrapHandlerWithErrorBoundary({ * metadata: { name: "my-handler", priority: HandlerPriority.MEDIUM }, * async handle(req, ctx) { * // Handler code * }, * }); * ``` */ export declare function wrapHandlerWithErrorBoundary(handler: Handler): Handler; /** * Convert any error to an RFC 9457 Response with environment-aware filtering * * Exported for reuse in route-executor and other HTTP boundaries that * need RFC 9457 responses without the full handler-wrapping middleware. */ export declare function errorToRFC9457Response(error: unknown, ctx: HandlerContext, req: Request): Response; //# sourceMappingURL=http-error-boundary.d.ts.map