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

Maps socket errors to SocketError objects subclassing httperrors.

  • 0.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8.1K
decreased by-1.51%
Maintainers
1
Weekly downloads
 
Created
Source

node-socketerrors

NPM version Build Status

Exposes a function mapping socket errors to SocketError objects.

The defined SocketError objects are created via createerror.

Installation

Make sure you have node.js and npm installed, then run:

npm install socketerrors

Usage

The primary use case is wrapping errors originating from socket operations:

var http = require('http');
var socketErrors = require('socketerrors');

http.get('nonexistent').on('error', function (err) {
    var socketError = socketErrors(err);

    console.warn(socketError.toString()); // ECONNREFUSED: connect ECONNREFUSED
});

Other errors will be marked as not being socket errors:

var socketErrors = require('socketerrors');

var err = new Error();
var socketError = socketErrors(err);

if (socketError.NotSocketError) {
    // what am I?
}

Mappings

The following is a list of socket errors mapped by this module:

  • EADDRINFO
  • ECONNABORTED
  • ECONNREFUSED
  • ECONNRESET
  • ENETDOWN
  • ENETRESET
  • ENETUNREACH
  • ETIMEDOUT

License

3-clause BSD license -- see the LICENSE file for details.

FAQs

Package last updated on 30 Oct 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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