Search code examples
javascriptgoogle-chromefirebugerror-reporting

Why does Firebug not show an 'Uncaught Type Error' for undefined properties?


I typically use Firebug for development, but lately some of my scripts have been failing silently. After hours of tracking down the error, I discovered I was attempting to get a property of an undefined variable. The console had no errors, the page just "broke". However, in the Chrome DevTools it correctly identifies the error. here is a simple test case:

var x = {
    i: {a:1,b:2}
}

In Chrome you get

console.log(x.i.a); //1
console.log(x.iii.a); //Uncaught TypeError: 
                      //Cannot read property 'a' of undefined 
console.log('finished'); //does not execute

In Firebug you get

console.log(x.i.a); //1
console.log(x.iii.a); //(nothing)
console.log('finished'); //does not execute

See this Fiddle.

So in a real script, when this happens, I have a seriously hard time tracking down where my script is halting, and I have to add a huge amount of console logging just to narrow down the error.

Is this a bug, or somehow the intended behavior of Firebug, or maybe there's a setting I can tweak? I'm using 2.0.3.


Solution

  • You need to check the option Show JavaScript Errors within the Console panel options menu.

    Show JavaScript Errors option

    As you can see, this makes the console correctly log the error message.