Bug 1245005 - don't report sync errors due to the application shutting down. r=rnewman

This commit is contained in:
Mark Hammond 2016-02-03 11:21:09 +11:00
parent 616a8f59bd
commit fccc1b4193

View File

@ -14,6 +14,7 @@ Cu.import("resource://services-sync/constants.js");
Cu.import("resource://services-sync/engines.js");
Cu.import("resource://services-sync/util.js");
Cu.import("resource://services-common/logmanager.js");
Cu.import("resource://services-common/async.js");
XPCOMUtils.defineLazyModuleGetter(this, "Status",
"resource://services-sync/status.js");
@ -577,18 +578,22 @@ ErrorHandler.prototype = {
this._log.debug(data + " failed to apply some records.");
}
break;
case "weave:engine:sync:error":
case "weave:engine:sync:error": {
let exception = subject; // exception thrown by engine's sync() method
let engine_name = data; // engine name that threw the exception
this.checkServerError(exception);
Status.engines = [engine_name, exception.failureCode || ENGINE_UNKNOWN_FAIL];
this._log.debug(engine_name + " failed", exception);
Services.telemetry.getKeyedHistogramById("WEAVE_ENGINE_SYNC_ERRORS")
.add(engine_name);
if (Async.isShutdownException(exception)) {
this._log.debug(engine_name + " was interrupted due to the application shutting down");
} else {
this._log.debug(engine_name + " failed", exception);
Services.telemetry.getKeyedHistogramById("WEAVE_ENGINE_SYNC_ERRORS")
.add(engine_name);
}
break;
}
case "weave:service:login:error":
this._log.error("Sync encountered a login error");
this.resetFileLog();
@ -601,12 +606,22 @@ ErrorHandler.prototype = {
this.dontIgnoreErrors = false;
break;
case "weave:service:sync:error":
case "weave:service:sync:error": {
if (Status.sync == CREDENTIALS_CHANGED) {
this.service.logout();
}
this._log.error("Sync encountered an error");
let exception = subject;
if (Async.isShutdownException(exception)) {
// If we are shutting down we just log the fact, attempt to flush
// the log file and get out of here!
this._log.error("Sync was interrupted due to the application shutting down");
this.resetFileLog();
break;
}
// Not a shutdown related exception...
this._log.error("Sync encountered an error", exception);
this.resetFileLog();
if (this.shouldReportError()) {
@ -617,6 +632,7 @@ ErrorHandler.prototype = {
this.dontIgnoreErrors = false;
break;
}
case "weave:service:sync:finish":
this._log.trace("Status.service is " + Status.service);