0.0.5 • Published 9 years ago

http-verror v0.0.5

Weekly downloads
5
License
GPLv3
Repository
github
Last release
9 years ago

http-verror - VError adaptation for usage with Express.js

Build Status Test Coverage Dependency Status

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); // 403
console.log(err.message); // You're not allowed to perform such action

var err2 = new errors.InternalError(new Error('Some preceding error with internal data'), 'Brief error desc');

console.log(err2.statusCode); // 500
console.log(err2.message); // Brief error desc
console.log(err2.cause().message); // Some preceding error with internal data
console.log(err2.toString()); // HttpError: Brief error desc; caused by Error: Some preceding error with internal data

Errors

Status codeName
400BadRequest
401Unauthorized
402PaymentRequired
403Forbidden
404NotFound
405MethodNotAllowed
406NotAcceptable
408RequestTimeout
409Conflict
412PreconditionFailed
415UnsupportedMediaType
500InternalError
501NotImplemented
502BadGateway
503ServiceUnavailable
504GatewayTimeout
0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2-r2

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago