UNPKG

@spfn/core

Version:

SPFN Framework Core - File-based routing, transactions, repository pattern

45 lines (41 loc) 1.06 kB
import { Context } from 'hono'; /** * Error Handler Middleware * * Generic middleware that converts errors with statusCode to HTTP responses */ interface ErrorHandlerOptions { /** * Include stack trace in response * @default process.env.NODE_ENV !== 'production' */ includeStack?: boolean; /** * Enable error logging * @default true */ enableLogging?: boolean; } /** * Standard error response format * * Used by ErrorHandler middleware for all error responses. * Compatible with ApiResponse pattern for consistent API responses. */ interface ErrorResponse { success: false; error: { message: string; type: string; statusCode: number; stack?: string; details?: any; }; } /** * Error handler middleware * * Used in Hono's onError hook */ declare function ErrorHandler(options?: ErrorHandlerOptions): (err: Error, c: Context) => Response | Promise<Response>; export { ErrorHandler as E, type ErrorHandlerOptions as a, type ErrorResponse as b };