Skip to content

Instantly share code, notes, and snippets.

@jay3sh
Created August 20, 2011 10:33
Show Gist options
  • Select an option

  • Save jay3sh/1158940 to your computer and use it in GitHub Desktop.

Select an option

Save jay3sh/1158940 to your computer and use it in GitHub Desktop.

Revisions

  1. Jayesh Salvi revised this gist Aug 20, 2011. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion stack-trace-without-exception.js
    Original file line number Diff line number Diff line change
    @@ -1,14 +1,17 @@

    function foo(args) {
    var i, j, k;
    // ...
    // j acquires some interesting value
    // Who called foo when j took this interesting value?
    //

    var e = new Error('dummy');
    var stack = e.stack.replace(/^[^\(]+?[\n$]/gm, '')
    .replace(/^\s+at\s+/gm, '')
    .replace(/^Object.<anonymous>\s*\(/gm, '{anonymous}()@')
    .split('\n');
    console.log(stack);

    // ...
    // rest of the code
    }
  2. Jayesh Salvi created this gist Aug 20, 2011.
    14 changes: 14 additions & 0 deletions stack-trace-without-exception.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@

    function foo(args) {
    var i, j, k;
    // ...
    // j acquires some interesting value
    // Who called foo when j took this interesting value?
    //
    var e = new Error('dummy');
    var stack = e.stack.replace(/^[^\(]+?[\n$]/gm, '')
    .replace(/^\s+at\s+/gm, '')
    .replace(/^Object.<anonymous>\s*\(/gm, '{anonymous}()@')
    .split('\n');
    console.log(stack);
    }