Simply creates http ERRORs with the given http error code.
npm install create-http-errorSimply creates http ERRORs with the given http error code.
``bash`
npm install --save create-http-error
`js
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.
`
#### HttpError(code [,message] [,properties])
creates an Error Object:code
- with the provided http error like e.g. 500message
- if the is omitted, the standard http error message is taken.properties
- if a Object is provided, it's properties will be added to the Error Object.
#### HttpError.toString()
returns the String representation of the HttpError.
#### HttpError.toJSON()
returns the Javascript Object properties of the HttpError Object.
#### HttpError.codes
exposes the standard http error codes.
bash
npm test
``