Permalink
Browse files

Handle error objects without stack property

This can happen for stack overflow errors.
  • Loading branch information...
1 parent fb424b7 commit a8e6d20c0aefe0ff768050a7e46683ede8fdcfb1 @felixge committed Aug 1, 2011
Showing with 11 additions and 0 deletions.
  1. +4 −0 lib/stack-trace.js
  2. +7 −0 test/integration/test-parse.js
View
@@ -18,6 +18,10 @@ exports.get = function(belowFn) {
};
exports.parse = function(err) {
+ if (!err.stack) {
+ return [];
+ }
+
var self = this;
var lines = err.stack.split('\n').slice(1);
@@ -19,6 +19,13 @@ var stackTrace = require(common.dir.lib + '/stack-trace');
})();
})();
+(function testNoStack() {
+ var err = {stack: undefined};
+ var trace = stackTrace.parse(err);
+
+ assert.deepEqual(trace, []);
+})();
+
(function testCorruptStack() {
var err = {};

0 comments on commit a8e6d20

Please sign in to comment.