| 1 | import { NextFunction, Request, Response } from "express"; |
| 2 | |
| 3 | export const handleErrors = ( |
| 4 | fn: (req: Request, res: Response, next: NextFunction) => Promise<any> |
| 5 | ) => { |
| 6 | return async (req: Request, res: Response, next: NextFunction) => { |
| 7 | try { |
| 8 | await fn(req, res, next); |
| 9 | } catch (error) { |
| 10 | next(error); |
| 11 | } |
| 12 | }; |
| 13 | }; |