Simple Express.js middleware middleware to handle errors for APIs and return correct status, error message and trace.
npm install --save @dimosbotsaris/express-error-handler
import { errorHandler } from '@dimosbotsaris/express-error-handler';
app.get('/bar', (req: Request, res: Response, next: NextFunction) => {
const error = new Error('Validation Error');
error.status = 400;
next(error);
});
app.use(errorHandler({}));
Option | Type | Default | Description |
---|---|---|---|
trace | Boolean | false |
If true the trace is attached to output. |
npm run test
👤 Dimos Botsaris
- Website: https://www.eldimious.com
- Twitter: @el_dimious
- Github: @eldimious
- LinkedIn: @dimosthenis-botsaris-5ab16485
Give a ⭐️ if this project helped you!