UNPKG

express-error-catcher

Version:
28 lines (22 loc) 1.12 kB
import { Request, Response as Response$1, NextFunction, ErrorRequestHandler } from 'express'; import * as qs from 'qs'; import * as express_serve_static_core from 'express-serve-static-core'; declare const tryCatch: (errFunction: Function) => (req: Request, res: Response$1, next: NextFunction) => Promise<void>; interface ErrorHandlerOptions { log?: "dev" | "pretty" | "production"; defaultStatusCode?: number; defaultErrorMessage?: string; } declare const errorHandler: ErrorRequestHandler<express_serve_static_core.ParamsDictionary, any, any, qs.ParsedQs, Record<string, any>> & ((options?: ErrorHandlerOptions) => ErrorRequestHandler); declare class Response { message: string | null; data: object | null; statusCode: number; constructor(message: string | null, data: object | any, statusCode: number); } declare class ErrorHandler extends Error { statusCode: number; data: object | null | undefined; constructor(message: string, statusCode: number, data?: object | null); } export { ErrorHandler as Error, Response, tryCatch as asyncErrorHandler, errorHandler as error };