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.1.1 to 0.2.0

39

lib/socketErrors.js

@@ -5,9 +5,39 @@ var createError = require('createerror');

var SocketError = createError({ name: 'SocketError' });
function allKeys(o) {
var keys = [];
for (var key in o) keys.push(key);
return keys;
}
function createSocketError(errorCode) {
var statusCode = socketCodesMap[errorCode] || 'Unknown';
return socketErrors[errorCode] = createError({
var options = {
name: errorCode,
code: errorCode
}, httpErrors[statusCode]);
code: errorCode,
statusCode: statusCode,
status: statusCode
};
// get constructed httpError to use to grab what we need to 'quack' like it
var httpError = httpErrors(statusCode);
var httpErrorKeys = allKeys(httpError);
// copy keys from the httpError to the socketError
httpErrorKeys.forEach(function (key) {
if (!options[key] && key !== 'message') {
options[key] = httpError[key];
}
});
// create the socket error object
var socketError = createError(options, SocketError);
socketErrors[errorCode] = socketError;
return socketError;
}

@@ -27,2 +57,5 @@

// export the base class
module.exports.SocketError = SocketError;
// create an Unknown error sentinel

@@ -29,0 +62,0 @@ socketErrors.NotSocketError = createSocketError('NotSocketError');

4

package.json
{
"name": "socketerrors",
"version": "0.1.1",
"version": "0.2.0",
"description": "Maps socket errors to SocketError objects subclassing httperrors.",

@@ -16,3 +16,3 @@ "main": "lib/socketErrors.js",

"createerror": "1.0.0",
"httperrors": "0.7.1"
"httperrors": "1.2.0"
},

@@ -19,0 +19,0 @@ "devDependencies": {

@@ -7,4 +7,3 @@ node-socketerrors

Exposes a function mapping socket errors to SocketError objects subclassing
<a href="https://github.com/One-com/node-httperrors">httperrors</a>.
Exposes a function mapping socket errors to SocketError objects.

@@ -11,0 +10,0 @@ The defined SocketError objects are created via

@@ -26,2 +26,4 @@ var expect = require('unexpected');

expect(socketError, 'to be a', socketErrors.SocketError);
done();

@@ -28,0 +30,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