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

yerror

Package Overview
Dependencies
Maintainers
2
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yerror - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

.eslintrc

19

package.json
{
"name": "yerror",
"version": "1.0.1",
"version": "1.0.2",
"description": "It helps to know why you got an error.",
"main": "src/index.js",
"scripts": {
"test": "node_modules/mocha/bin/mocha tests/*.mocha.js",
"coveralls": "./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha --report lcovonly -- tests/*.mocha.js -R spec -t 5000 && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage",
"cover": "./node_modules/istanbul/lib/cli.js cover --report html ./node_modules/mocha/bin/_mocha -- tests/*.mocha.js -R spec -t 5000"
"test": "mocha tests/*.mocha.js",
"coveralls": "istanbul cover _mocha --report lcovonly -- tests/*.mocha.js -R spec -t 5000 && cat ./coverage/lcov.info | coveralls && rm -rf ./coverage",
"cover": "istanbul cover --report html _mocha -- tests/*.mocha.js -R spec -t 5000",
"cli": "env NPM_RUN_CLI=1",
"lint": "eslint src/index.js tests/index.mocha.js",
"preversion": "npm run lint && npm test"
},

@@ -29,8 +32,10 @@ "engines": {

"devDependencies": {
"mocha": "~2.2.5",
"mocha-lcov-reporter": "0.0.2",
"coveralls": "~2.11.2",
"istanbul": "~0.3.17"
"eslint": "^1.10.3",
"eslint-config-simplifield": "^1.2.0",
"istanbul": "^0.4.2",
"mocha": "^2.4.5",
"mocha-lcov-reporter": "^1.0.0"
},
"dependencies": {}
}

@@ -0,1 +1,3 @@

'use strict';
var util = require('util');

@@ -39,3 +41,3 @@ var os = require('os');

var yError = null;
var wrappedErrorIsACode = /^([A-Z0-9_]+)$/.test(err.message);
var wrappedErrorIsACode = (/^([A-Z0-9_]+)$/).test(err.message);
if(!errorCode) {

@@ -60,3 +62,3 @@ if(wrappedErrorIsACode) {

if(err instanceof YError) {
return err;
return err;
}

@@ -74,2 +76,1 @@ return YError.wrap.apply(YError, arguments);

module.exports = YError;

@@ -0,1 +1,3 @@

'use strict';
var assert = require('assert');

@@ -10,2 +12,3 @@ var YError = require('../src');

var err = new YError('E_ERROR', 'arg1', 'arg2');
assert(err instanceof Error);

@@ -19,2 +22,3 @@ assert.equal(err.name, err.toString());

var err = new YError();
assert.equal(err.code, 'E_UNEXPECTED');

@@ -27,2 +31,3 @@ assert.deepEqual(err.params, []);

var err = new YError('E_ERROR', 'arg1', 'arg2');
assert.equal(err.code, 'E_ERROR');

@@ -41,7 +46,14 @@ assert(err instanceof YError);

var err = YError.wrap(new Error('This is an error!'));
assert.equal(err.code, 'E_UNEXPECTED');
assert.equal(err.wrappedErrors.length, 1);
assert.deepEqual(err.params, ['This is an error!']);
assert(-1 !== err.stack.indexOf('Error: This is an error!'), 'Stack contains original error.');
assert(-1 !== err.stack.indexOf('YError: E_UNEXPECTED (This is an error!)'), 'Stack contains cast error.');
assert(
-1 !== err.stack.indexOf('Error: This is an error!'),
'Stack contains original error.'
);
assert(
-1 !== err.stack.indexOf('YError: E_UNEXPECTED (This is an error!)'),
'Stack contains cast error.'
);
assert.equal(err.name, err.toString());

@@ -52,7 +64,14 @@ });

var err = YError.wrap(new Error('E_ERROR'));
assert.equal(err.code, 'E_ERROR');
assert.equal(err.wrappedErrors.length, 1);
assert.deepEqual(err.params, []);
assert(-1 !== err.stack.indexOf('Error: E_ERROR'), 'Stack contains original error.');
assert(-1 !== err.stack.indexOf('YError: E_ERROR ()'), 'Stack contains cast error.');
assert(
-1 !== err.stack.indexOf('Error: E_ERROR'),
'Stack contains original error.'
);
assert(
-1 !== err.stack.indexOf('YError: E_ERROR ()'),
'Stack contains cast error.'
);
assert.equal(err.name, err.toString());

@@ -63,7 +82,14 @@ });

var err = YError.wrap(new Error('E_ERROR'), 'E_ERROR_2', 'arg1', 'arg2');
assert.equal(err.code, 'E_ERROR_2');
assert.equal(err.wrappedErrors.length, 1);
assert.deepEqual(err.params, ['arg1', 'arg2']);
assert(-1 !== err.stack.indexOf('Error: E_ERROR'), 'Stack contains first error.');
assert(-1 !== err.stack.indexOf('YError: E_ERROR_2 (arg1, arg2)'), 'Stack contains second error.');
assert(
-1 !== err.stack.indexOf('Error: E_ERROR'),
'Stack contains first error.'
);
assert(
-1 !== err.stack.indexOf('YError: E_ERROR_2 (arg1, arg2)'),
'Stack contains second error.'
);
assert.equal(err.name, err.toString());

@@ -84,8 +110,18 @@ });

);
assert.equal(err.code, 'E_ERROR_3');
assert.equal(err.wrappedErrors.length, 2);
assert.deepEqual(err.params, ['arg3.1', 'arg3.2']);
assert(-1 !== err.stack.indexOf('Error: E_ERROR_1'), 'Stack contains first error.');
assert(-1 !== err.stack.indexOf('YError: E_ERROR_2 (arg2.1, arg2.2)'), 'Stack contains second error.');
assert(-1 !== err.stack.indexOf('YError: E_ERROR_3 (arg3.1, arg3.2)'), 'Stack contains second error.');
assert(
-1 !== err.stack.indexOf('Error: E_ERROR_1'),
'Stack contains first error.'
);
assert(
-1 !== err.stack.indexOf('YError: E_ERROR_2 (arg2.1, arg2.2)'),
'Stack contains second error.'
);
assert(
-1 !== err.stack.indexOf('YError: E_ERROR_3 (arg3.1, arg3.2)'),
'Stack contains second error.'
);
assert.equal(err.name, err.toString());

@@ -100,7 +136,14 @@ });

var err = YError.cast(new Error('This is an error!'));
assert.equal(err.code, 'E_UNEXPECTED');
assert.equal(err.wrappedErrors.length, 1);
assert.deepEqual(err.params, ['This is an error!']);
assert(-1 !== err.stack.indexOf('Error: This is an error!'), 'Stack contains original error.');
assert(-1 !== err.stack.indexOf('YError: E_UNEXPECTED (This is an error!)'), 'Stack contains cast error.');
assert(
-1 !== err.stack.indexOf('Error: This is an error!'),
'Stack contains original error.'
);
assert(
-1 !== err.stack.indexOf('YError: E_UNEXPECTED (This is an error!)'),
'Stack contains cast error.'
);
assert.equal(err.name, err.toString());

@@ -111,5 +154,9 @@ });

var err = YError.cast(new YError('E_ERROR', 'arg1', 'arg2'));
assert.equal(err.code, 'E_ERROR');
assert.deepEqual(err.params, ['arg1', 'arg2']);
assert(-1 !== err.stack.indexOf('YError: E_ERROR (arg1, arg2)'), 'Stack contains cast error.');
assert(
-1 !== err.stack.indexOf('YError: E_ERROR (arg1, arg2)'),
'Stack contains cast error.'
);
assert.equal(err.name, err.toString());

@@ -124,7 +171,14 @@ });

var err = YError.bump(new Error('This is an error!'));
assert.equal(err.code, 'E_UNEXPECTED');
assert.equal(err.wrappedErrors.length, 1);
assert.deepEqual(err.params, ['This is an error!']);
assert(-1 !== err.stack.indexOf('Error: This is an error!'), 'Stack contains original error.');
assert(-1 !== err.stack.indexOf('YError: E_UNEXPECTED (This is an error!)'), 'Stack contains bumped error.');
assert(
-1 !== err.stack.indexOf('Error: This is an error!'),
'Stack contains original error.'
);
assert(
-1 !== err.stack.indexOf('YError: E_UNEXPECTED (This is an error!)'),
'Stack contains bumped error.'
);
assert.equal(err.name, err.toString());

@@ -134,7 +188,17 @@ });

it('Should work with Y errors and a message', function() {
var err = YError.bump(new YError('E_ERROR', 'arg1.1', 'arg1.2'), 'E_ERROR_2', 'arg2.1', 'arg2.2');
var err = YError.bump(
new YError('E_ERROR', 'arg1.1', 'arg1.2'),
'E_ERROR_2', 'arg2.1', 'arg2.2'
);
assert.equal(err.code, 'E_ERROR');
assert.deepEqual(err.params, ['arg1.1', 'arg1.2']);
assert(-1 !== err.stack.indexOf('YError: E_ERROR (arg1.1, arg1.2)'), 'Stack contains original error.');
assert(-1 !== err.stack.indexOf('YError: E_ERROR (arg1.1, arg1.2)'), 'Stack contains bumped error.');
assert(
-1 !== err.stack.indexOf('YError: E_ERROR (arg1.1, arg1.2)'),
'Stack contains original error.'
);
assert(
-1 !== err.stack.indexOf('YError: E_ERROR (arg1.1, arg1.2)'),
'Stack contains bumped error.'
);
assert.equal(err.name, err.toString());

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