Created
June 29, 2020 16:40
-
-
Save birendra-b/8494767e185f62616fbbe0154c2421af to your computer and use it in GitHub Desktop.
Server.ts with API bad request error handler
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
// Print API errors | |
// eslint-disable-next-line @typescript-eslint/no-unused-vars | |
app.use((err: Error, req: Request, res: Response, next: NextFunction) => { | |
logger.error(err.message, err); | |
return res.status(BAD_REQUEST).json({ | |
error: err.message, | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment