19

I have noticed that even with "show stack trace with errors" enabled from the drop down, only errors that occur seem to have traces, but when I do: throw new Error('foo'); I do not see any stack trace for it even though it seems to appear in the console exactly the same way as other errors that occur such as iDoNotExist().

Is there something I am missing?

It also seems that I get the stack trace for calling console.error('foo');. Odd.

It should be noted that stack traces do occur on Webkit Inspector and Opera when doing throw new Error('foo');.

Tower
  • 98,741
  • 129
  • 357
  • 507

3 Answers3

20

For others landing here :

The issue for me was showStackTrace is set to false by default for Firebug.

Here's how to enable it :

  1. Goto about:config in Firefox

  2. Change the value of the preference extensions.firebug.showStackTrace from false to true (Double-click toggles the value).

coding_idiot
  • 13,526
  • 10
  • 65
  • 116
  • The question mentions that the option *Show Stack Trace with Errors* is already enabled, which toggles exactly that preference. So this answer does not solve the initial problem. I guess this was a bug in an earlier version of Firebug. – Sebastian Zartner Nov 05 '14 at 21:23
  • The answer may not solve the initial problem, but it sure solved my problem. +1 – Lasse Nov 24 '15 at 15:00
  • I would like to gratulate to the firebug developers for this nice config change. – peterh Dec 04 '16 at 01:29
0

I tested this code in Firebug 1.7.1b2 (FF: 4.0.1, on win7) and it shows me stack trace:

function a(){
    throw new Error('s');
};

function b(){
    a()
}

b();
pmaruszczyk
  • 2,157
  • 2
  • 24
  • 49
0

Have you tried:

var err = new Error();  
err.name = 'My custom error';
err.message = 'foo';  
throw(err);

Or even (doesn't always work):

throw 'foo';
throw('foo');
Mathieu Rodic
  • 6,637
  • 2
  • 43
  • 49