UNPKG

@wthek/express-middleware

Version:

Express middleware for handling and formatting errors using http-error-kit. Ensures structured error responses with correct status codes.

15 lines 895 B
import { Request, Response, NextFunction } from "express"; /** * KitExpressMiddleware is a middleware for Express.js to handle errors in a standard * and customizable way. The middleware will inspect the error and if it is an instance * of KitHttpError or KitGeneralError, it will use the error's details to construct a * response with the appropriate status code. If the error is not an instance of KitHttpError * or KitGeneralError, the middleware will call the next function to propagate the error. * * @param {unknown} error The error to be handled. * @param {Request} req The Express.js request object. * @param {Response} res The Express.js response object. * @param {NextFunction} next The Express.js next function. */ export declare function KitExpressMiddleware(): (error: unknown, req: Request, res: Response, next: NextFunction) => void; //# sourceMappingURL=index.d.ts.map