1.0.3 ā€¢ Published 2 years ago

@dimosbotsaris/express-error-handler v1.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

Simple Express.js middleware middleware to handle errors for APIs and return correct status, error message and trace.

Install

npm install --save @dimosbotsaris/express-error-handler

Usage

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({}));

Options

OptionTypeDefaultDescription
traceBooleanfalseIf true the trace is attached to output.

Run tests

npm run test

Author

šŸ‘¤ Dimos Botsaris

Support Me

ko-fi

Show your support

Give a ā­ļø if this project helped you!