UNPKG

@visulima/error-handler

Version:

Error handlers for use in development and production environments.

27 lines (26 loc) 981 B
import type { IncomingMessage, ServerResponse } from "node:http"; import type { ErrorHandler } from "./types.d.d.ts"; export type XmlErrorBody = Record<string, unknown> | unknown[]; export type XmlErrorFormatter = (parameters: { error: Error; reasonPhrase: string; request: IncomingMessage; response: ServerResponse; statusCode: number; }) => XmlErrorBody | Promise<XmlErrorBody>; export type ToXmlOptions = { attributeExplicitTrue?: boolean; attributeFilter?: (key: string, value: unknown) => boolean; attributeReplacements?: Record<string, string>; contentMap?: (content: string) => string; contentReplacements?: Record<string, string>; header?: string | boolean; indent?: string; selfCloseTags?: boolean; }; export type XmlErrorHandlerOptions = { formatter?: XmlErrorFormatter; toXml?: ToXmlOptions; xmlHeader?: boolean; }; export declare const xmlErrorHandler: (options?: XmlErrorHandlerOptions) => ErrorHandler;