UNPKG

handle-http-errors

Version:

Type-safe HTTP error handling package providing error classes, standardized responses, error handler, and built-in Express middleware support.

21 lines (20 loc) 504 B
export interface ErrorDetails { [key: string]: string | number | boolean | undefined | ErrorDetails; } export interface ErrorResponse { status: number; code: string; message: string; timestamp: string; details?: ErrorDetails; stack?: string; } export interface HttpResponse { status(code: number): { json(data: unknown): unknown; }; } export interface ErrorHandlerOptions { includeStack?: boolean; onError?: (error: unknown) => void | Promise<void>; }