Skip to content

Commit 342ce18

Browse files
Fixes stacktracejs#47 - error message is added to stack when access to caller is forbidden (strict mode)
1 parent 96c41b3 commit 342ce18

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

stacktrace.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,11 @@
3636

3737
printStackTrace.implementation.prototype = {
3838
/**
39-
* @param {Error} ex The error to create a stacktrace from (optional)
40-
* @param {String} mode Forced mode (optional, mostly for unit tests)
39+
* @param {Error} [ex] The error to create a stacktrace from (optional)
40+
* @param {String} [mode] Forced mode (optional, mostly for unit tests)
4141
*/
4242
run: function(ex, mode) {
4343
ex = ex || this.createException();
44-
// examine exception properties w/o debugger
45-
//for (var prop in ex) {alert("Ex['" + prop + "']=" + ex[prop]);}
4644
mode = mode || this.mode(ex);
4745
if (mode === 'other') {
4846
return this.other(arguments.callee);
@@ -274,7 +272,12 @@
274272
fn = fnRE.test(curr.toString()) ? RegExp.$1 || ANON : ANON;
275273
args = Array.prototype.slice.call(curr['arguments'] || []);
276274
stack[stack.length] = fn + '(' + this.stringifyArguments(args) + ')';
277-
curr = curr.caller;
275+
try {
276+
curr = curr.caller;
277+
} catch (e) {
278+
stack[stack.length] = '' + e;
279+
break;
280+
}
278281
}
279282
return stack;
280283
},

0 commit comments

Comments
 (0)