socketerrors
Advanced tools
Comparing version 0.0.1 to 0.1.0
module.exports = { | ||
EADDRINFO: 502, | ||
ECONNABORTED: 502, | ||
@@ -3,0 +4,0 @@ ECONNREFUSED: 504, |
@@ -9,3 +9,4 @@ var createError = require('createerror'); | ||
return socketErrors[errorCode] = createError({ | ||
name: errorCode | ||
name: errorCode, | ||
code: errorCode | ||
}, httpErrors[statusCode]); | ||
@@ -12,0 +13,0 @@ } |
{ | ||
"name": "socketerrors", | ||
"version": "0.0.1", | ||
"description": "Maps socket errors to SocketError objects subclassing httpErrors.", | ||
"version": "0.1.0", | ||
"description": "Maps socket errors to SocketError objects subclassing httperrors.", | ||
"main": "lib/socketErrors.js", | ||
@@ -6,0 +6,0 @@ "scripts": { |
node-httperrors | ||
=============== | ||
[![NPM version](https://badge.fury.io/js/socketerrors.svg)](http://badge.fury.io/js/socketerrors) | ||
[![Build Status](https://travis-ci.org/alexjeffburke/node-socketerrors.svg?branch=master)](https://travis-ci.org/alexjeffburke/unode-socketerrors) | ||
Exposes a function mapping socket errors to SocketError objects subclassing | ||
<a href="https://github.com/One-com/node-httperrors">httpErrors</a>. | ||
<a href="https://github.com/One-com/node-httperrors">httperrors</a>. | ||
The defined SocketError objects are created via | ||
<a href="https://github.com/One-com/node-createerror">createError</a>. | ||
<a href="https://github.com/One-com/node-createerror">createerror</a>. | ||
@@ -28,3 +31,3 @@ Installation | ||
console.warn(err.toString()); // ECONNREFUSED: connect ECONNREFUSED | ||
console.warn(socketError.toString()); // ECONNREFUSED: connect ECONNREFUSED | ||
}); | ||
@@ -44,3 +47,16 @@ | ||
Mappings | ||
-------- | ||
The following is a list of socket errors mapped by this module: | ||
* EADDRINFO | ||
* ECONNABORTED | ||
* ECONNREFUSED | ||
* ECONNRESET | ||
* ENETDOWN | ||
* ENETRESET | ||
* ENETUNREACH | ||
* ETIMEDOUT | ||
License | ||
@@ -47,0 +63,0 @@ ------- |
var expect = require('unexpected'); | ||
var httpErrors = require('httpErrors'); | ||
var httpErrors = require('httperrors'); | ||
var http = require('http'); | ||
@@ -11,3 +11,3 @@ var socketCodesMap = require('../lib/socketCodesMap'); | ||
// capture a genuine ECONNREFUSED error | ||
http.get('nonexistent').on('error', function (err) { | ||
http.get('http://localhost:59891/').on('error', function (err) { | ||
var socketError = socketErrors(err); | ||
@@ -78,2 +78,16 @@ var httpError = new httpErrors[504](); | ||
}); | ||
it('lets the `code` from the original instance take precedence over the one built into the class', function () { | ||
var err = new Error(); | ||
err.code = 'SOMETHINGELSE'; | ||
var socketError = socketErrors(err); | ||
expect(socketError.code, 'to equal', 'SOMETHINGELSE'); | ||
}); | ||
describe('when instantiated via the constructor', function () { | ||
it('has a `code` property', function () { | ||
expect(new socketErrors[errorCode]().code, 'to equal', errorCode); | ||
}); | ||
}); | ||
}); | ||
@@ -80,0 +94,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
8072
9
104
64