3

I am using window.onerror & $(document).ajaxError method and I am aware that I can get the js name and line number. But in my case the js files are minified and clubbed because of which both these information are obsolete for me.

Is their any way by which I can log the name and parameters of the function where the error occurred.

Per Hornshøj-Schierbeck
  • 15,097
  • 21
  • 80
  • 101
Varun Sharma
  • 306
  • 3
  • 14
  • 1
    To be fair to Varun - this question is not a duplicate! Varun - there is no way to get meaningful stack trace once you minify your JS files. That is the reason why your build process should ensure your code runs in un-minified format in dev environment. That way if you face any problems you can fire up your dev build, reproduce the problem and debug it using the stack trace in un-minified version. Hope that helps! – RaviH Feb 10 '14 at 15:59
  • The data which I am logging currently points me towards a particular function but I am not sure whether it is the one causing error. Is their any way by which I can log some runtime information about that function for eg ... surround the code(from where that function gets called) with a try and catch block and log something from error object ... Suggestions will appreciated .. – Varun Sharma Feb 11 '14 at 06:22
  • In firebug set a break point on the line before the line causing this problem. You can see the stack when the debugger stops on the break point. – RaviH Feb 11 '14 at 06:25
  • The js error I am talking here is not reproduce-able on local and dev. I want to put some loggers in prod. so that I can get enough information to reproduce it on local. – Varun Sharma Feb 11 '14 at 06:38
  • There can't be a problem you can't reproduce in dev. Only thing is - you have to find the way to reproduce it. Sometimes problems may be data dependent. Find out what data produces the problem. – RaviH Feb 11 '14 at 06:40

0 Answers0