When logging nsresult values, convert to a human-readable string representation

RESOLVED FIXED in mozilla19

Status

()

Toolkit
Add-ons Manager
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: rnewman, Assigned: Unfocused)

Tracking

unspecified
mozilla19
Points:
---
Bug Flags:
in-testsuite -

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

6 years ago
I'm having trouble debugging Bug 804480, so it's time to add some logging.
(Reporter)

Comment 1

6 years ago
Meh, not important enough.
Status: ASSIGNED → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → WORKSFORME
Yes, important enough :) I'm always on the lookout to improve the usefulness of the Add-ons Manager logging.

The download failed log isn't terribly humane there, just logging the integer value of the status code (bug 759642 fixes almost every case of that but this one). So that, at least, is an easy win.
Assignee: rnewman → bmcbride
Status: RESOLVED → REOPENED
Resolution: WORKSFORME → ---
Summary: Additional logging in XPIProvider → Log a more humane message when xpi download fails
Summary: Log a more humane message when xpi download fails → When logging nsresult values, convert to a human-readable string representation
Created attachment 674515 [details] [diff] [review]
Patch v1

A more generic fix to make AddonLogger smarter. Components.Exception().name is a convenient but slightly obscure way to convert between a nsresult value and a string representation of that value.

This makes it so running something like this:
  AddonManager.getInstallForURL("http://something.invalid/notthere.xpi",
                                function(install) { install.install(); },
                                "application/x-xpinstall");

Will result in the following log output:
  Warning: WARN addons.xpi: Download failed: NS_ERROR_UNKNOWN_HOST

Instead of the existing log output:
  Warning: WARN addons.xpi: Download failed: 2152398878
Attachment #674515 - Flags: review?(dtownsend+bugmail)
(Reporter)

Comment 4

6 years ago
Comment on attachment 674515 [details] [diff] [review]
Patch v1

Review of attachment 674515 [details] [diff] [review]:
-----------------------------------------------------------------

That would save me some time with <http://james-ross.co.uk/mozilla/misc/nserror>!
Attachment #674515 - Flags: feedback+
Comment on attachment 674515 [details] [diff] [review]
Patch v1

Review of attachment 674515 [details] [diff] [review]:
-----------------------------------------------------------------

Clever trick
Attachment #674515 - Flags: review?(dtownsend+bugmail) → review+
https://hg.mozilla.org/integration/fx-team/rev/3e9ca49bd35f
Whiteboard: [fixed-in-fx-team]
Target Milestone: --- → mozilla19
https://hg.mozilla.org/mozilla-central/rev/3e9ca49bd35f
Status: REOPENED → RESOLVED
Last Resolved: 6 years ago6 years ago
Flags: in-testsuite-
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
You need to log in before you can comment on or make changes to this bug.