Guest User

Untitled

a guest
Dec 15th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. import { Request, Response, NextFunction, Router } from "express";
  2. import * as ErrorHandler from "../utils/ErrorHandler";
  3.  
  4. const handle404Error = (router: Router) => {
  5. router.use((req: Request, res: Response) => {
  6. ErrorHandler.notFoundError();
  7. });
  8. };
  9.  
  10. const handleClientError = (router: Router) => {
  11. router.use((err: Error, req: Request, res: Response, next: NextFunction) => {
  12. ErrorHandler.clientError(err, res, next);
  13. });
  14. };
  15.  
  16. const handleServerError = (router: Router) => {
  17. router.use((err: Error, req: Request, res: Response, next: NextFunction) => {
  18. ErrorHandler.serverError(err, res, next);
  19. });
  20. };
  21.  
  22. export default [handle404Error, handleClientError, handleServerError];
Add Comment
Please, Sign In to add comment