Bug 855040 - Add a bit of logging in the crash report to help diagnostics and silence exception of crash report is disabled. r=fabrice

This commit is contained in:
Hubert Figuière 2013-04-22 16:09:15 -04:00
parent 492fe7b2d5
commit 6b1000074d

View File

@ -84,6 +84,14 @@ function debug(str) {
dump(' -*- Shell.js: ' + str + '\n');
}
#ifdef MOZ_CRASHREPORTER
function debugCrashReport(aStr) {
dump('Crash reporter : ' + aStr);
}
#else
function debugCrashReport(aStr) {}
#endif
var shell = {
get CrashSubmit() {
@ -92,6 +100,7 @@ var shell = {
Cu.import("resource://gre/modules/CrashSubmit.jsm", this);
return this.CrashSubmit;
#else
dump('Crash reporter : disabled at build time.');
return this.CrashSubmit = null;
#endif
},
@ -111,7 +120,10 @@ var shell = {
crashID = Cc["@mozilla.org/xre/app-info;1"]
.getService(Ci.nsIXULRuntime).lastRunCrashID;
}
} catch(e) { }
} catch(e) {
debugCrashReport('Failed to fetch crash id. Crash ID is "' + crashID
+ '" Exception: ' + e);
}
// Bail if there isn't a valid crashID.
if (!this.CrashSubmit || !crashID && !this.CrashSubmit.pendingIDs().length) {
@ -123,10 +135,14 @@ var shell = {
try {
// Check if we should automatically submit this crash.
if (Services.prefs.getBoolPref("app.reportCrashes")) {
if (Services.prefs.getBoolPref('app.reportCrashes')) {
this.submitCrash(crashID);
} else {
debugCrashReport('app.reportCrashes is disabled');
}
} catch (e) { }
} catch (e) {
debugCrashReport('Can\'t fetch app.reportCrashes. Exception: ' + e);
}
// We can get here if we're just submitting old pending crashes.
// Check that there's a valid crashID so that we only notify the
@ -146,6 +162,7 @@ var shell = {
// submit the pending queue.
let pending = shell.CrashSubmit.pendingIDs();
for (let crashid of pending) {
debugCrashReport('Submitting crash: ' + crashid);
shell.CrashSubmit.submit(crashid);
}
},
@ -157,6 +174,8 @@ var shell = {
return;
}
debugCrashReport('Not online, postponing.');
Services.obs.addObserver(function observer(subject, topic, state) {
let network = subject.QueryInterface(Ci.nsINetworkInterface);
if (network.state == Ci.nsINetworkInterface.NETWORK_STATE_CONNECTED
@ -242,7 +261,7 @@ var shell = {
});
#endif
} catch(e) {
dump("exception: " + e);
debugCrashReport('exception: ' + e);
}
let homeURL = this.homeURL;