2024-08-11 16:12:51 +07:00
|
|
|
import { Request, Response, NextFunction } from 'express';
|
|
|
|
|
|
2024-08-11 16:54:21 +07:00
|
|
|
const exceptionHandler = (fn: (req: Request, res: Response, next: NextFunction) => any) =>
|
2024-08-11 16:12:51 +07:00
|
|
|
(req: Request, res: Response, next: NextFunction) => {
|
2024-08-27 14:34:43 +07:00
|
|
|
Promise.resolve(fn(req, res, next)).catch((e) => {
|
2025-05-06 17:02:58 +07:00
|
|
|
console.log(e);
|
|
|
|
|
|
2024-08-27 14:34:43 +07:00
|
|
|
next();
|
|
|
|
|
});
|
2024-08-11 16:12:51 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default exceptionHandler;
|