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.
14 lines
406 B
14 lines
406 B
7 years ago
|
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;
|