express-response-errors
Advanced tools
Weekly downloads
Readme
Collection of custom response errors and middleware for Express.
npm i express-response-errors -S
Add middleware to your application bootstrap file:
const { responseErrorHandler } = require('express-response-errors');
app.use(responseErrorHandler);
Pass HttpError exception with required code and optional message to Express from route handler.
const { HttpError } = require('express-response-errors');
// Ex. with default status text
next(new HttpError(418));
// Ex. with custom message
next(new HttpError(418, 'I only brew tea'));
Pass a specific http exception with optional message to Express from route handler.
const { ImATeapotError } = require('express-response-errors');
// Ex. with default status text
next(new ImATeapotError());
// Ex. with custom status text
next(new ImATeapotError('I only brew tea'));
Errors passed to Express without a message defaults to HTTP standard status text.
Errors are handled by middleware which sends related error message and status as a HTTP response.
FAQs
Collection of custom response errors and middleware for express
The npm package express-response-errors receives a total of 794 weekly downloads. As such, express-response-errors popularity was classified as not popular.
We found that express-response-errors demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.