http-verror
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -11,2 +11,14 @@ /** | ||
var httpErrors = { | ||
400: { name: 'BadRequest', description: 'Invalid data was sent to the server' }, | ||
401: { name: 'Unauthenticated', description: 'You\'re not authorized to perform such action' }, | ||
403: { name: 'Forbidden', description: 'You\'re not allowed to perform such action' }, | ||
404: { name: 'NotFound', description: 'Resource was not found' }, | ||
409: { name: 'Conflict', description: 'Item exists or dependency absent' }, | ||
500: { name: 'InternalError', description: 'Unexpected internal error' }, | ||
502: { name: 'BadGateway', description: 'Bad gateway' }, | ||
503: { name: 'Unavailable', description: 'Not available' }, | ||
504: { name: 'GatewayTimeout', description: 'Gateway time-out' } | ||
}; | ||
function HttpError (code) { | ||
@@ -16,6 +28,5 @@ this.statusCode = code; | ||
if (arguments.length < 2) | ||
WError.call(this, errors[this.statusCode].description); | ||
else { | ||
WError.call(this, httpErrors[this.statusCode].description); | ||
else | ||
WError.apply(this, Array.prototype.slice.call(arguments, 1)); | ||
} | ||
@@ -30,19 +41,9 @@ return this; | ||
var errors = { | ||
400: { name: 'BadRequest', description: 'Invalid data was sent to the server' }, | ||
401: { name: 'Unauthenticated', description: 'You\'re not authorized to perform such action' }, | ||
403: { name: 'Forbidden', description: 'You\'re not allowed to perform such action' }, | ||
404: { name: 'NotFound', description: 'Resource was not found' }, | ||
409: { name: 'Conflict', description: 'Item exists or dependency absent' }, | ||
500: { name: 'InternalError', description: 'Unexpected internal error' }, | ||
502: { name: 'BadGateway', description: 'Bad gateway' }, | ||
503: { name: 'Unavailable', description: 'Not available' }, | ||
504: { name: 'GatewayTimeout', description: 'Gateway time-out' } | ||
}, exports = {}; | ||
var errors = {}; | ||
Object.keys(errors).forEach(function (errorCode) { | ||
var error = errors[errorCode]; | ||
exports[error.name] = new E(+errorCode); | ||
Object.keys(httpErrors).forEach(function (errorCode) { | ||
var error = httpErrors[errorCode]; | ||
errors[error.name] = new E(+errorCode); | ||
}); | ||
module.exports = exports; | ||
module.exports = exports = errors; |
{ | ||
"name": "http-verror", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "A simple tool that provides `verror` functionality extended by usable HTTP error codes for Express.js", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "mocha", | ||
"coverage": "mocha --require blanket -R html-cov > coverage.html" | ||
"test": "mocha -R list", | ||
"test-cov": "mocha --require blanket -R html-cov > coverage.html" | ||
}, | ||
@@ -19,4 +19,11 @@ "keywords": [ | ||
"author": "Dr. Evil <dr.evil@krtn.eu>", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/v12/node-http-verror.git" | ||
}, | ||
"homepage": "https://github.com/v12/node-http-verror", | ||
"bugs": "https://github.com/v12/node-http-verror/issues", | ||
"license": "GPLv3", | ||
"dependencies": { | ||
"mocha-lcov-reporter": "0.0.1", | ||
"verror": "^1.6.0" | ||
@@ -23,0 +30,0 @@ }, |
# http-verror - VError adaptation for usage with Express.js | ||
[![Build Status](https://travis-ci.org/v12/node-http-verror.svg)](https://travis-ci.org/v12/node-http-verror) [![Test Coverage](https://codeclimate.com/github/v12/node-http-verror/badges/coverage.svg)](https://codeclimate.com/github/v12/node-http-verror) [![Dependency Status](https://david-dm.org/v12/node-http-verror.svg)](https://david-dm.org/v12/node-http-verror) | ||
## Installation | ||
```npm install http-verror --save``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
37588
18
1
6
0
2
+ Addedmocha-lcov-reporter@0.0.1
+ Addedmocha-lcov-reporter@0.0.1(transitive)