Socket
Socket
Sign inDemoInstall

fasterror

Package Overview
Dependencies
Maintainers
3
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fasterror - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

10

index.js

@@ -7,5 +7,11 @@ var util = require('util');

function FastError() {
this.message = util.format.apply(null, arguments);
this.name = name;
Error.captureStackTrace(this, arguments.callee);
if (arguments[0] && arguments[0] instanceof Error) {
this.message = arguments[0].message;
this.stack = arguments[0].stack.replace(arguments[0].name, name);
} else {
this.message = util.format.apply(null, arguments);
Error.captureStackTrace(this, arguments.callee);
}
}

@@ -12,0 +18,0 @@

2

package.json
{
"name": "fasterror",
"version": "1.0.0",
"version": "1.1.0",
"description": "Quickly create custom error objects.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -45,2 +45,20 @@ var fasterror = require('../index');

});
test('[error constructor] should copy message and stack from constructing error', function(assert) {
var MyError = fasterror('MyError');
var sourceErr = new TypeError('bad type');
var err = new MyError(sourceErr);
assert.equal(err.message, 'bad type');
assert.ok(err.stack.match(/^MyError: bad type/));
// Is set to 47:21 to indicate it came from the `TypeError` line
assert.ok(err.stack.match(/error.test.js:47:21/));
assert.end();
});
test('[error constructor] should set default code for constructing error', function(assert) {
var MyError = fasterror('MyError', {code: 'code'});
var sourceErr = new TypeError('bad type');
var err = new MyError(sourceErr);
assert.equal(err.message, 'bad type');
assert.equal(err.code, 'code');
assert.end();
});

@@ -47,0 +65,0 @@ test('[error object] should perform string interpolation on provided arguments', function(assert) {

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