You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

15 lines
407 B

import * as express from "express";
import ApiError from "@common/ApiError";
const errorHandler: express.ErrorRequestHandler =
(err: any, req: express.Request, res: express.Response, next: express.NextFunction) => {
if (err instanceof ApiError) {
res.status(err.statusCode).json(err.toJSON());
} else {
next(err);
}
};
export default errorHandler;