Skip to content

Instantly share code, notes, and snippets.

@alexpermiakov
Last active June 14, 2019 16:23
Show Gist options
  • Save alexpermiakov/278fbd6446abc57e931b73ff59b80d56 to your computer and use it in GitHub Desktop.
Save alexpermiakov/278fbd6446abc57e931b73ff59b80d56 to your computer and use it in GitHub Desktop.
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