Permalink
Browse files

[bug] solves issues with different v8 errors in node 0.4

* fixes #3
  • Loading branch information...
dscape committed Mar 3, 2012
1 parent b4d61c0 commit 17d90b95ccefdafd0085164abee147ff5cb446b5
Showing with 9 additions and 5 deletions.
  1. +6 −2 lib/errs.js
  2. +3 −3 test/errs-test.js
View
@@ -126,9 +126,13 @@ exports.merge = function (err, type, opts) {
// optional stuff that might be created by module
Object.keys(err).forEach(function (key) {
- merged[key] = err[key];
+ // in node v0.4 v8 errors where treated differently
+ // we need to make sure we aren't merging these properties
+ if(['stack', 'type', 'arguments', 'message'].indexOf(key)===-1) {
+ merged[key] = err[key];
+ }
});
-
+
// merging
merged.name = merged.name || err.name;
merged.message = merged.message || err.message;
View
@@ -131,17 +131,17 @@ vows.describe('errs').addBatch({
},
"should have a stack trace": function () {
var err = new Error('Msg!');
- err = errs.merge(err, {message: "Override!", ns: "test"});
+ err = errs.merge(err, {});
assert.isTrue(Array.isArray(err.stacktrace));
},
"should preserve message specified in create": function () {
var err = new Error('Msg!');
- err = errs.merge(err, {message: "Override!", ns: "test"});
+ err = errs.merge(err, {message: "Override!"});
assert.equal(err.message, "Override!");
},
"should preserve properties specified": function () {
var err = new Error('Msg!');
- err = errs.merge(err, {message: "Override!", ns: "test"});
+ err = errs.merge(err, {ns: "test"});
assert.equal(err.ns, "test");
}
}

0 comments on commit 17d90b9

Please sign in to comment.