View Full Version : Obtaining call stack programatically

16 Jan 2013, 1:53 AM
Hi All,

I am trying to detect a tricky and hard to reproduce issue in my code and I need to obtain call stack programmatically. Is there anything is ext-js-4 that could help in doing that?


17 Jan 2013, 1:56 PM
You can use a try/catch block

18 Jan 2013, 1:21 AM
Hmmm - there is no exception involved - it is more about seeing from where certain methods are invoked and why. So if they get called and hist certain condition I would like to see the full call stack in an alert or logs.

18 Jan 2013, 2:31 AM
If you just want to kick off the debugger you can add a breakpoint or use the debugger statement in your code. Most browsers support conditional breakpoints so that they only pause execution if some condition is met.

However, to answer your question directly:

var stack = new Error().stack

18 Jan 2013, 4:02 AM
You can google for 'javascript stack trace' and you will find quite a few pages on different ways to do it.

21 Jan 2013, 5:30 AM
Since I need to capture a stacktrace when the issue happens and there is a very little chance to do so when debugger is on I used the following library: https://github.com/eriwen/javascript-stacktrace