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 6.0.0 to 6.1.0

2

package.json
{
"name": "error",
"version": "6.0.0",
"version": "6.1.0",
"description": "Custom errors",

@@ -5,0 +5,0 @@ "keywords": [],

@@ -49,2 +49,24 @@ 'use strict';

test('can create wrapped error with syscall', function t(assert) {
var SysCallError = WrappedError({
'message': 'tchannel socket error ({code} from ' +
'{syscall}): {origMessage}',
type: 'syscall.error'
});
var err = new Error('listen EADDRINUSE');
err.code = 'EADDRINUSE';
err.syscall = 'listen';
var err2 = SysCallError(err);
assert.equal(err2.message, 'tchannel socket error ' +
'(EADDRINUSE from listen): listen EADDRINUSE');
assert.equal(err2.syscall, 'listen');
assert.equal(err2.code, 'EADDRINUSE');
assert.equal(err2.type, 'syscall.error');
assert.end();
});
test('can wrap real IO errors', function t(assert) {

@@ -51,0 +73,0 @@ var ServerListenError = WrappedError({

@@ -35,34 +35,27 @@ 'use strict';

var err = createTypedError(extend(opts, {
var nodeCause = false;
var errOptions = extend(opts, {
causeMessage: cause.message,
origMessage: cause.message
}));
});
var nodeCause = false;
if (has(cause, 'code') && !has(err, 'code')) {
err.code = cause.code;
if (has(cause, 'code') && !has(errOptions, 'code')) {
errOptions.code = cause.code;
}
if (has(cause, 'errno') && !has(err, 'errno')) {
err.errno = cause.errno;
if (has(cause, 'errno') && !has(errOptions, 'errno')) {
errOptions.errno = cause.errno;
nodeCause = true;
}
if (has(cause, 'syscall') && !has(err, 'syscall')) {
err.syscall = cause.syscall;
if (has(cause, 'syscall') && !has(errOptions, 'syscall')) {
errOptions.syscall = cause.syscall;
nodeCause = true;
}
Object.defineProperty(err, 'cause', {
value: cause,
configurable: true,
enumerable: false
});
var causeType = err.cause.type;
var causeType = cause.type;
if (!causeType && nodeCause) {
causeType = 'error.wrapped-io.' +
(err.syscall || 'unknown') + '.' +
(err.errno || 'unknown');
(cause.syscall || 'unknown') + '.' +
(cause.errno || 'unknown');
} else {

@@ -72,5 +65,12 @@ causeType = 'error.wrapped-unknown';

err.fullType = err.type + '~!~' +
(err.cause.type || causeType);
errOptions.fullType = options.type + '~!~' +
(cause.type || causeType);
var err = createTypedError(errOptions);
Object.defineProperty(err, 'cause', {
value: cause,
configurable: true,
enumerable: false
});
return err;

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