she swears <i>geek</i> is a term of endearment

JQuery Error troubleshooting

As is usually the case with javascript errors, a recent error I encountered was difficult to track down to its source.  Firebug was kind enough to indicate that there was a bug, but the message and line at which it occurred was not very helpful.  The exception was thrown from deep inside the minified jQuery library.

uncaught exception: [Exception… "Could not convert JavaScript argument arg 0 [nsIDOMViewCSS.getComputedStyle]" nsresult: "0×80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: …/jquery-1.3.2.min.js :: anonymous :: line 12" data: no]

unhelpful-error

Not very helpful!

I’ve seen this exception before and Googling it brought me a number of exceptions related to dimensions manipulations.  However, nothing concrete was evident. 

I’m curious to know if there is some way to bring the stack trace forward from firebug as I see several indications that this is possible.

Another opportunity is to set FireBug to “break on all Errors” under Script > Options.  This can be tricky because you’ll find it breaking on quite a number of calls inside jQuery.  I found that this did, indeed, break on the line that was causing the error in MY code but it was not easy to click through the other errors to find it. 

More Info please Javascript Detail in FireBug

strict-warningsA useful option is to increase the noise level for FireBug.  A big warning indicates that you shouldn’t leave this option on all the time.  However, its very useful when you need it.

Under Console, choose Options > Strict Warnings.

This will increase the information that FireBug reports on.

You can now look at the messages preceding the non-helpful message to see if, perhaps, something is leading up to the problem.

more-firebug-error-info

That’s more like it!  Now I can see that, right before the JSFrame Exception, I had another warning in my own lobrary: reference to undefined property this.items[this.selectedIdx]

I added one short line that checked the length of a selected object so that it could exit if it was not there and my error went away.

FireBug is certainly the tool of the decade for web programming and I have no idea what this world would be like without itl

Leave a Reply