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

VERIFIED FIXED in mozilla2.0b8

Status

()

Toolkit
Add-ons Manager
VERIFIED FIXED
7 years ago
7 years ago

People

(Reporter: mossop, Assigned: mossop)

Tracking

Trunk
mozilla2.0b8
Points:
---
Bug Flags:
in-testsuite -
in-litmus -

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Assignee)

Description

7 years ago
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.
(Assignee)

Comment 1

7 years ago
Created attachment 489543 [details] [diff] [review]
patch rev 1

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)
(Assignee)

Updated

7 years ago
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+
(Assignee)

Comment 3

7 years ago
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+
(Assignee)

Comment 4

7 years ago
Landed http://hg.mozilla.org/mozilla-central/rev/56e0c37647b7
Status: NEW → RESOLVED
Last Resolved: 7 years ago
Flags: in-testsuite-
Flags: in-litmus-
Resolution: --- → FIXED
Whiteboard: [has patch][needs review rs]
Target Milestone: --- → mozilla2.0b8
(Assignee)

Comment 5

7 years ago
Backed out due to windows debug test failures
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
(Assignee)

Comment 6

7 years ago
Re-landed as this wasn't the cause of the bustage: http://hg.mozilla.org/mozilla-central/rev/2a3cc3bffc66
Status: REOPENED → RESOLVED
Last Resolved: 7 years ago7 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.