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 = ; var err = ; console; // 403console; // You're not allowed to perform such action var err2 = 'Some preceding error with internal data' 'Brief error desc'; console; // 500console; // Brief error descconsole; // Some preceding error with internal dataconsole; // HttpError: Brief error desc; caused by Error: Some preceding error with internal data
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 |