Greasy Fork is available in English.

Discussions » Development

Debugging: throw new typeError not showing up in Firebug

§
Posted: 16-03-2015
Edited: 17-03-2015

Debugging: throw new typeError not showing up in Firebug

Firefox 36+
Greasemonkey 3.0

I apologise if this has already been discussed, I have used Greasy Fork and Google search across the internet and they turned up nothing of relevance.

When scripting I use try catch and throw new Error. However for some period of time, the output of those exceptions have only been visible in the browser console (Ctrl+Shift J) and not in Firebug console (Show JavaScript Errors checked). I get every other type of console.log message in both, just not the exceptions.

Does anyone know how to get exceptions showing up in Firebug please?

EDIT: What I meant to say is: exceptions caught with try catch are reported in both browser and Firebug, however exceptions generated outside of try catch are only reported in the browser console, not Firebug

§
Posted: 17-03-2015

I wrote a little testscript which works for me:

// ==UserScript==
// @name        Test
// @namespace   TobbetestTestscript
// @include     https://greasyfork.org/de/forum/discussion/*
// @version     1
// @grant       none
// ==/UserScript==

try {
  throw new Error('Foo Bar');
} catch(exception) {
  console.log(exception);
}

Also if I set the grant to unsafeWindow everything works fine and I see the error. So it might be necessary that you can provide a (for you) non-working example.

§
Posted: 17-03-2015

My description wasn't very well written, I'll add an edit to clarify. However thank you for your script because it is helpful, and it does illustrate what works in my tests, so we're on common ground. Where exception fails for me is outside catch try.
I tried @grant unsafeWindow and it didn't make much difference.

// ==UserScript==
// @name        exception test
// @namespace   ecofriend
// @include     https://greasyfork.org/de/forum/discussion/*
// @version     1
// @grant       none
// ==/UserScript==

console.log('exception reporting - without try catch;');

// exceptions outside try catch are reported in the browser console (not Firebug)
throw new Error('food bar');
//throw new TypeError('food bar');

try {
//	throw new Error('food bar');
//	throw new TypeError('food bar');
}
catch(exception) {
	console.error(exception);
}

I grabbed screenshots of the two scenarios; with and without try catch.

woxxomMod
§
Posted: 17-03-2015

And what Firebug developers say?

§
Posted: 18-03-2015

I had hoped I would find the answer here.

§
Posted: 18-03-2015

To me it doesn't look like a Firebug bug. The normal console also does not display errors thrown by a script which are not catched. It looks more like a Greasemonkey bug to me. So I'd suggest to report it to the Greasemonkey development team: https://github.com/greasemonkey/greasemonkey

§
Posted: 18-03-2015

Thank you both for your input. I'll see what Greasemonkey and then Firebug have to say. I'll report back here if I find anything out.

Post reply

Sign in to post a reply.