1.0.0 • Published 5 years ago

socketerrors v1.0.0

Weekly downloads
4,616
License
BSD
Repository
github
Last release
5 years ago

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.

1.0.0

5 years ago

0.3.0

7 years ago

0.2.0

9 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.1

10 years ago