Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

http-verror

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

http-verror - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2-r2

.idea/inspectionProfiles/profiles_settings.xml

131

lib/index.js
/**
* @file http-verror
* @module http-verror
* @copyright Dr. Evil <dr.evil@krtn.eu> - 21/11/2014

@@ -11,2 +12,95 @@ */

var httpErrors = {
/**
* HTTP status code 400
*
* @constructor
* @name BadRequest
* @memberOf errors
*/
400: { name: 'BadRequest', description: 'Invalid data was sent to the server' },
/**
* HTTP status code 401
*
* @constructor
* @name Unauthenticated
* @memberOf errors
*/
401: { name: 'Unauthenticated', description: 'You\'re not authorized to perform such action' },
/**
* HTTP status code 403
*
* @static
* @name Forbidden
* @memberOf errors
*/
403: { name: 'Forbidden', description: 'You\'re not allowed to perform such action' },
/**
* HTTP status code 404
*
* @constructor
* @name NotFound
* @memberOf errors
*/
404: { name: 'NotFound', description: 'Resource was not found' },
/**
* HTTP status code 409
*
* @constructor
* @name Conflict
* @memberOf errors
*/
409: { name: 'Conflict', description: 'Item exists or dependency absent' },
/**
* HTTP status code 500
*
* @constructor
* @name InternalError
* @memberOf errors
*/
500: { name: 'InternalError', description: 'Unexpected internal error' },
/**
* HTTP status code 502
*
* @constructor
* @name BadGateway
* @memberOf errors
*/
502: { name: 'BadGateway', description: 'Bad gateway' },
/**
* HTTP status code 503
*
* @constructor
* @name Unavailable
* @memberOf errors
*/
503: { name: 'Unavailable', description: 'Not available' },
/**
* HTTP status code 504
*
* @constructor
* @name GatewayTimeout
* @memberOf errors
*/
504: { name: 'GatewayTimeout', description: 'Gateway time-out' }
};
/**
* @private
* @constructor
* @name HttpError
* @augments WError
*
* @param {Number} code
*
* @returns {HttpError}
*/
function HttpError (code) {

@@ -16,6 +110,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));
}

@@ -26,2 +119,10 @@ return this;

/**
* @private
* @class
* @name E
* @param {Number} code HTTP status code
* @returns {HttpError}
* @constructor
*/
function E (code) {

@@ -31,19 +132,13 @@ return HttpError.bind(this, code);

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 = {};
/**
* @class errors
* @name errors
*/
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;

14

package.json
{
"name": "http-verror",
"version": "0.0.1",
"version": "0.0.2-r2",
"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,2 +19,8 @@ "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",

@@ -25,4 +31,4 @@ "dependencies": {

"devDependencies": {
"mocha-lcov-reporter": "0.0.1",
"blanket": "^1.1.6",
"expect.js": "^0.3.1",
"mocha": "^2.0.1"

@@ -29,0 +35,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```
'use strict';
var expect = require('expect.js'),
/* jshint mocha:true */
var assert = require('assert'),
errors = require('../lib');

@@ -14,4 +16,4 @@

expect(e.statusCode).to.be.equal(400);
expect(e.message).to.be.equal('Invalid data was sent to the server');
assert.strictEqual(e.statusCode, 400);
assert.strictEqual(e.message, 'Invalid data was sent to the server');
});

@@ -22,6 +24,6 @@

expect(e.statusCode).to.be.equal(403);
expect(e.message).to.be.equal('we don\'t show that it was test error');
expect(e.cause().message).to.be.equal('test error');
assert.strictEqual(e.statusCode, 403);
assert.strictEqual(e.message, 'we don\'t show that it was test error');
assert.strictEqual(e.cause().message, 'test error');
});
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc