http-verror - VError adaptation for usage with Express.js
Installation
npm install http-verror --save
Usage
http-verror instance inherits all properties of WError. In other words, http-verror is a WError but with statusCode
property being equal to the HTTP status code of the error you created.
Example
var errors = require('http-verror');
var err = new errors.Forbidden();
console.log(err.statusCode);
console.log(err.message);
var err2 = new errors.InternalError(new Error('Some preceding error with internal data'), 'Brief error desc');
console.log(err2.statusCode);
console.log(err2.message);
console.log(err2.cause().message);
console.log(err2.toString());
Errors
Status code | Name |
---|
400 | BadRequest |
401 | Unauthorized |
402 | PaymentRequired |
403 | Forbidden |
404 | NotFound |
405 | MethodNotAllowed |
406 | NotAcceptable |
408 | RequestTimeout |
409 | Conflict |
412 | PreconditionFailed |
415 | UnsupportedMediaType |
500 | InternalError |
501 | NotImplemented |
502 | BadGateway |
503 | ServiceUnavailable |
504 | GatewayTimeout |