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

socketerrors

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

socketerrors - npm Package Compare versions

Comparing version 0.0.1 to 0.1.0

.travis.yml

1

lib/socketCodesMap.js
module.exports = {
EADDRINFO: 502,
ECONNABORTED: 502,

@@ -3,0 +4,0 @@ ECONNREFUSED: 504,

3

lib/socketErrors.js

@@ -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 @@ });

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