Last active
June 14, 2019 16:23
-
-
Save alexpermiakov/278fbd6446abc57e931b73ff59b80d56 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