Venkman planning for Gecko 1.9, part 3

Thanks to Gijs and Mnyromyr (and not to me; I didn’t write a single line of code), Venkman’s met three of the six bullet points I listed in my initial Venkman planning post. It is now at least minimally useful for Gecko 1.9 code.

I would strongly encourage Firefox developers (and for that matter, most of us who hack on trunk) to launch the JavaScript Debugger at startup (command-line argument is -venkman), and turn on “Stop for Exceptions”. You’ll find a few pain points pretty quickly. My personal favorite looks something like this:

try {
var foo =;
} catch (e) {};

This code is wrong, in my opinion, on three levels:

  1. The empty catch block, which always annoys me. A comment saying “do nothing” would be better than that.
  2. No checking of what e is. In this example, only one line is inside the try block, but you can’t tell if the QI failed, or if myObj is undefined. It could be the QI failure is expected, but if myObj being missing is a Bad Thing, that exception needs to propagate.
  3. A simple instanceof check removes the need to try and catch. If you can avoid generating an exception, then by all means do so. Exceptions like this are just useless (and probably expensive from a JSENG/XPConnect point of view). Exceptions should be thrown for exceptional circumstances.
var foo = ( instanceof Components.interfaces.nsIFoo) ? : null;

I’m not intending to point fingers, but autocomplete in the URL bar is an extremely visible case of this being a problem for Venkman…

Time is running out for any of these changes we want to get into Firefox 3. If we’re fast enough, though, we can clean up a lot of these useless “noise” errors which discourage people from using Venkman – and thus make exceptions it catches more relevant to whatever problem the user is debugging.


3 thoughts on “Venkman planning for Gecko 1.9, part 3”

  1. It is saddening if code like that passed a review. 🙁
    (From Alex: Why? For the most part, this doesn’t affect users. It only becomes a problem when you debug. Of course, I debug a lot. So for me, it’s painful, but most people won’t notice.)

  2. Most folks are testing minefield (or granparadiso) builds which sadly don’t come with venkman. Top of my list would be building venkman into minefield and making nightly builds of venkman available to install into grandparadiso.
    (From Alex: For Venkman XPI’s, talk to Robert Kaiser.)

Comments are closed.