Comparing version 0.2.4 to 0.3.0
@@ -130,3 +130,3 @@ /* | ||
// ### function merge (err, type, opts) | ||
// #### @err {error} The error to merge | ||
// #### @err {error} **Optional** The error to merge | ||
// #### @type {string} **Optional** Registered error type to create | ||
@@ -146,2 +146,9 @@ // #### @opts {string|object|Array|function} Options for creating the error: | ||
// | ||
// If there is no error just return the merged one | ||
// | ||
if (err == undefined || err == null) { | ||
return merged; | ||
} | ||
// | ||
// optional stuff that might be created by module | ||
@@ -173,3 +180,3 @@ // | ||
} | ||
if (err.stack && err.stack.split) { | ||
@@ -176,0 +183,0 @@ merged.stacktrace = err.stack.split("\n"); |
{ | ||
"name": "errs", | ||
"description": "Simple error creation and passing utilities", | ||
"version": "0.2.4", | ||
"version": "0.3.0", | ||
"author": "Nodejitsu Inc. <info@nodejitsu.com>", | ||
@@ -19,3 +19,3 @@ "maintainers": [ | ||
"devDependencies": { | ||
"vows": "0.6.x" | ||
"vows": "0.7.x" | ||
}, | ||
@@ -22,0 +22,0 @@ "main": "./lib/errs", |
@@ -8,3 +8,3 @@ /* | ||
*/ | ||
var assert = require('assert'), | ||
@@ -80,3 +80,3 @@ events = require('events'), | ||
stream = new events.EventEmitter(); | ||
stream.once('error', this.callback.bind(this, null)); | ||
@@ -95,3 +95,3 @@ errs.handle(err, stream); | ||
that = this; | ||
function onError(err) { | ||
@@ -102,3 +102,3 @@ if (++invoked === 2) { | ||
} | ||
stream.once('error', onError); | ||
@@ -115,3 +115,3 @@ errs.handle(err, onError, stream); | ||
emitter = errs.handle(err); | ||
emitter.once('error', this.callback.bind(this, null)); | ||
@@ -137,2 +137,24 @@ }, | ||
"the merge() method": { | ||
"supports": { | ||
"an undefined error": function () { | ||
var err = errs.merge(undefined, { message: 'oh noes!' }); | ||
assert.equal(err.message, 'oh noes!') | ||
assert.instanceOf(err, Error); | ||
}, | ||
"a null error": function () { | ||
var err = errs.merge(null, { message: 'oh noes!' }); | ||
assert.equal(err.message, 'oh noes!') | ||
assert.instanceOf(err, Error); | ||
}, | ||
"a false error": function () { | ||
var err = errs.merge(false, { message: 'oh noes!' }); | ||
assert.equal(err.message, 'oh noes!') | ||
assert.instanceOf(err, Error); | ||
}, | ||
"a string error": function () { | ||
var err = errs.merge('wat', { message: 'oh noes!' }); | ||
assert.equal(err.message, 'oh noes!'); | ||
assert.instanceOf(err, Error); | ||
}, | ||
}, | ||
"should preserve custom properties": function () { | ||
@@ -190,5 +212,5 @@ var err = new Error('Msg!'); | ||
assert.isFunction(Error.prototype.toJSON); | ||
var json = (new Error('Testing 12345')).toJSON(); | ||
['message', 'stack', 'arguments', 'type'].forEach(function (prop) { | ||
@@ -195,0 +217,0 @@ assert.isObject(Object.getOwnPropertyDescriptor(json, prop)); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27467
593