This package has been deprecated

Author message:

Package is deprecated in favour of `boom`

http-verror

0.0.5 • Public • Published

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 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

Package Sidebar

Install

npm i http-verror

Weekly Downloads

206

Version

0.0.5

License

GPLv3

Last publish

Collaborators

  • v6