How to get firebug to break on exception?

2020-03-08 08:56发布

I'm using Firebug 1.5.4. When I reference an undefined variable or some such, it breaks right where the problem occurs, and throws me into the debug view where I can see the stack and inspect variables.

However, when I throw my own exception, it just takes me to the console and prints out "uncaught exception: blah". I'd like it to break and let me inspect variables. How can I tell Firebug to do this?

标签: firebug
4条回答
Deceive 欺骗
2楼-- · 2020-03-08 09:51

Put a debugger; statement in your code or use the Script tab of firebug to click on a line number (which inserts a breakpoint).

If you only want to do it when you throw an exception, you could put the debugger statement in a catch block.

查看更多
家丑人穷心不美
3楼-- · 2020-03-08 09:52

Call Web Developer Debugger (Tools => Web Developer => Debugger or Ctrl + Shift + S), click gear icon and check "Pause on exception":

enter image description here

Or execute debugger; in Web Developer Console!

Official Web Developer Debugger docs: https://developer.mozilla.org/en-US/docs/Tools/Debugger

查看更多
We Are One
4楼-- · 2020-03-08 09:56

The respondent was helpful but neglected something very key I was missing; the window.onerror event. Here is the full code:

 window.onerror = function(msg) {
   debugger;
 }
查看更多
相关推荐>>
5楼-- · 2020-03-08 10:00

Install Firebug 1.6b1 http://getfirebug.com/releases/firebug/1.6X, Firebug > Console > "the exception" Click the breakpoint selector in the left column. Run your code. Firebug breaks on that line.

Or Firebug > Console > [||] breaks on next error

查看更多
登录 后发表回答