-
-
Save tridungle/5b1c98abdfedeb0dbb37d647d3bc079a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Request, Response, NextFunction, Router } from "express"; | |
import * as ErrorHandler from "../utils/ErrorHandler"; | |
const handle404Error = (router: Router) => { | |
router.use((req: Request, res: Response) => { | |
ErrorHandler.notFoundError(); | |
}); | |
}; | |
const handleClientError = (router: Router) => { | |
router.use((err: Error, req: Request, res: Response, next: NextFunction) => { | |
ErrorHandler.clientError(err, res, next); | |
}); | |
}; | |
const handleServerError = (router: Router) => { | |
router.use((err: Error, req: Request, res: Response, next: NextFunction) => { | |
ErrorHandler.serverError(err, res, next); | |
}); | |
}; | |
export default [handle404Error, handleClientError, handleServerError]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment