Closed Bug 610810 Opened 14 years ago Closed 14 years ago

Add file and line number information to ERROR and WARN messages in the console

Categories

(Toolkit :: Add-ons Manager, defect)

defect
Not set
normal

Tracking

()

VERIFIED FIXED
mozilla2.0b8

People

(Reporter: mossop, Assigned: mossop)

Details

Attachments

(1 file)

Going forward I'm anticipating that we'll start to see strange error messages that at first glance are had to explain (like bug 603248). One step we can take is to figure out the specific line that is throwing exceptions and include that in the log. This can help narrow things down a bit.
Attached patch patch rev 1Splinter Review
By passing excplicit extension objects through to the logging methods we can both log the exception and pull file and line number info from them. In their absence we can just use the stack to figure out where was calling the logging method. Also helped me spot a stupid error in the xpinstall/head.js file so that's a win right?
Attachment #489543 - Flags: review?(robert.bugzilla)
Whiteboard: [has patch][needs review rs]
Comment on attachment 489543 [details] [diff] [review]
patch rev 1

>diff --git a/toolkit/mozapps/extensions/AddonManager.jsm b/toolkit/mozapps/extensions/AddonManager.jsm
>--- a/toolkit/mozapps/extensions/AddonManager.jsm
>+++ b/toolkit/mozapps/extensions/AddonManager.jsm
>@@ -76,17 +76,17 @@ const DEFAULT_PROVIDERS = [
>  */
> function safeCall(aCallback) {
>   var args = Array.slice(arguments, 1);
> 
>   try {
>     aCallback.apply(null, args);
>   }
>   catch (e) {
>-    WARN("Exception calling callback: " + e);
>+    WARN("Exception calling callback", e);
>   }
> }
> 
> /**
>  * Calls a method on a provider if it exists and consumes any thrown exception.
>  * Any parameters after the dflt parameter are passed to the provider's method.
>  *
>  * @param  aProvider
>@@ -102,18 +102,19 @@ function safeCall(aCallback) {
> function callProvider(aProvider, aMethod, aDefault) {
>   if (!(aMethod in aProvider))
>     return aDefault;
> 
>   var args = Array.slice(arguments, 3);
> 
>   try {
>     return aProvider[aMethod].apply(aProvider, args);
>-  } catch (e) {
>-    ERROR("Exception calling provider." + aMethod + ": " + e);
>+  }
>+  catch (e) {
>+    ERROR("Exception calling provider." + aMethod, e);
Should there be a space after the "." or should the "." be removed?
Attachment #489543 - Flags: review?(robert.bugzilla) → review+
Comment on attachment 489543 [details] [diff] [review]
patch rev 1

Straightforward risk-free patch that gives us better information for diagnosing problems in the future
Attachment #489543 - Flags: approval2.0+
Landed http://hg.mozilla.org/mozilla-central/rev/56e0c37647b7
Status: NEW → RESOLVED
Closed: 14 years ago
Flags: in-testsuite-
Flags: in-litmus-
Resolution: --- → FIXED
Whiteboard: [has patch][needs review rs]
Target Milestone: --- → mozilla2.0b8
Backed out due to windows debug test failures
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Re-landed as this wasn't the cause of the bustage: http://hg.mozilla.org/mozilla-central/rev/2a3cc3bffc66
Status: REOPENED → RESOLVED
Closed: 14 years ago14 years ago
Resolution: --- → FIXED
Verified fixed based on landing.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: