views:

36

answers:

2

I am trying to make firebug break when an error is detected. Specifically, I have some internal checks in my code, like assertions, that I want firebug to stop on when they fail. I have tried a few different ways and wondered what other people do? Here are the ways I have tried:

  1. Put in some invalid code so that if errors out: function assert(value) { if(! value) dbgbreak(); } // Fails because dbgbreak not defined

This works somewhat, but does not stop the code in such a way that I can see the stack or examine local variables.

  1. Have it throw an exeption: function assert(value) { if ! value) throw AssertExecption(); }

This is prettier, but still when I track exceptions I can't see the stack or the locals

  1. Put a breakpoint on the assert failure. This works, however, it means everytime I run my code I have to manually put in a bunch of breakpoints.

What do other people do in terms of working with the debugger and asserts, and similar consistency checks?

+1  A: 

Have you tried throwing down the "debugger" keyword in your script where you want it to stop?

James
A: 

On the console tab there is a button for breaking on all errors. Turn that on, and it will automatically break when an error occurs.

http://getfirebug.com/wiki/index.php/Console_Panel#Break_On_All_Errors

David