Simply creates http ERRORs with the given http error code.
npm install --save create-http-error
var HttpError = require('create-http-error');
// e.g. as finalhandler after no route matched.
function finalhandler (req, res, next) {
next(HttpError('400'));
}
app.use(finalhandler); // connect or express app.
creates an Error
Object:
- with the provided http error
code
like e.g. 500 - if the
message
is omitted, the standardhttp
error message is taken. - if a
properties
Object is provided, it's properties will be added to theError
Object.
returns the String
representation of the HttpError
.
returns the Javascript Object properties of the HttpError
Object.
exposes the standard http
error codes.
npm test
MIT