3

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?

JessicaB
  • 498
  • 4
  • 10

2 Answers2

2

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

James
  • 12,636
  • 12
  • 67
  • 104
  • 2
    Could you try improving this answer so that it makes sense and tells people like me (who found this answer via google) what we need to do? – Timwi Sep 05 '11 at 19:05
  • Just to clarify, already answered: http://stackoverflow.com/questions/1265623/programmatically-stop-javascript-execution-in-firefox-firebug – xtrm May 17 '13 at 10:10
2

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
  • 333
  • 1
  • 7