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

error

Package Overview
Dependencies
Maintainers
2
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

error - npm Package Compare versions

Comparing version 5.2.0 to 6.0.0-experiment2

8

io.js

@@ -5,4 +5,4 @@ 'use strict';

function IOError(originalError, prefix) {
var err = new Error(prefix + ': ' + originalError.message);
function IOError(cause, prefix) {
var err = new Error(prefix + ': ' + cause.message);

@@ -16,4 +16,4 @@ Object.defineProperty(err, 'type', {

err.statusCode = 500;
Object.defineProperty(err, 'original', {
value: originalError,
Object.defineProperty(err, 'cause', {
value: cause,
configurable: true,

@@ -20,0 +20,0 @@ enumerable: false

{
"name": "error",
"version": "5.2.0",
"version": "6.0.0-experiment2",
"description": "Custom errors",

@@ -19,3 +19,3 @@ "keywords": [],

},
"dependencies": {
"fakeProductionDependencies": {
"camelize": "^1.0.0",

@@ -22,0 +22,0 @@ "is-error": "^2.0.0",

@@ -10,3 +10,3 @@ 'use strict';

var ServerListenError = WrappedError({
message: 'server: {origMessage}',
message: 'server: {causeMessage}',
type: 'server.listen-failed',

@@ -30,3 +30,3 @@ requestedPort: null,

assert.equal(err2.original, err);
assert.equal(err2.cause, err);

@@ -42,4 +42,6 @@ assert.equal(err2.toString(),

name: 'ServerListenFailedError',
causeMessage: 'listen EADDRINUSE',
origMessage: 'listen EADDRINUSE',
code: 'EADDRINUSE'
code: 'EADDRINUSE',
fullType: 'server.listen-failed~!~error.wrapped-unknown'
}));

@@ -52,3 +54,3 @@

var ServerListenError = WrappedError({
message: 'server: {origMessage}',
message: 'server: {causeMessage}',
type: 'server.listen-failed',

@@ -71,4 +73,4 @@ requestedPort: null,

function onError(originalError) {
var err = ServerListenError(originalError, {
function onError(cause) {
var err = ServerListenError(cause, {
host: 'localhost',

@@ -79,7 +81,7 @@ requestedPort: port

otherServer.close();
assertOnError(err, originalError, port);
assertOnError(err, cause, port);
}
}
function assertOnError(err, originalError, port) {
function assertOnError(err, cause, port) {
assert.equal(err.message, 'server: listen EADDRINUSE');

@@ -90,3 +92,3 @@ assert.equal(err.requestedPort, port);

assert.equal(err.original, originalError);
assert.equal(err.cause, cause);

@@ -102,6 +104,9 @@ assert.equal(err.toString(),

name: 'ServerListenFailedError',
causeMessage: 'listen EADDRINUSE',
origMessage: 'listen EADDRINUSE',
code: 'EADDRINUSE',
errno: 'EADDRINUSE',
syscall: 'listen'
syscall: 'listen',
fullType: 'server.listen-failed~!~' +
'error.wrapped-io.listen.EADDRINUSE'
}));

@@ -108,0 +113,0 @@

@@ -16,4 +16,8 @@ 'use strict';

assert(!has(options, 'original'),
'WrappedError: original field is reserved');
assert(!has(options, 'cause'),
'WrappedError: cause field is reserved');
assert(!has(options, 'fullType'),
'WrappedError: fullType field is reserved');
assert(!has(options, 'causeMessage'),
'WrappedError: causeMessage field is reserved');
assert(!has(options, 'origMessage'),

@@ -26,25 +30,31 @@ 'WrappedError: origMessage field is reserved');

function createError(originalError, opts) {
assert(originalError, 'an error is required');
assert(isError(originalError),
function createError(cause, opts) {
/*eslint max-statements: [2, 25]*/
assert(cause, 'an error is required');
assert(isError(cause),
'WrappedError: first argument must be an error');
var err = createTypedError(extend(opts, {
origMessage: originalError.message
causeMessage: cause.message,
origMessage: cause.message
}));
if (has(originalError, 'code') && !has(err, 'code')) {
err.code = originalError.code;
var nodeCause = false;
if (has(cause, 'code') && !has(err, 'code')) {
err.code = cause.code;
}
if (has(originalError, 'errno') && !has(err, 'errno')) {
err.errno = originalError.errno;
if (has(cause, 'errno') && !has(err, 'errno')) {
err.errno = cause.errno;
nodeCause = true;
}
if (has(originalError, 'syscall') && !has(err, 'syscall')) {
err.syscall = originalError.syscall;
if (has(cause, 'syscall') && !has(err, 'syscall')) {
err.syscall = cause.syscall;
nodeCause = true;
}
Object.defineProperty(err, 'original', {
value: originalError,
Object.defineProperty(err, 'cause', {
value: cause,
configurable: true,

@@ -54,2 +64,14 @@ enumerable: false

var causeType = err.cause.type;
if (!causeType && nodeCause) {
causeType = 'error.wrapped-io.' +
(err.syscall || 'unknown') + '.' +
(err.errno || 'unknown');
} else {
causeType = 'error.wrapped-unknown';
}
err.fullType = err.type + '~!~' +
(err.cause.type || causeType);
return err;

@@ -56,0 +78,0 @@ }

Sorry, the diff of this file is not supported yet

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