From 52ca6d4713a51bdd4caad6ebea7b5d6b6bf305ff Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 6 May 2016 04:59:04 -0400 Subject: [PATCH] Handle browser-offline error from anywhere in sync code And don't throw from ConcurrentCaller, because it results in an unhandled rejection --- .../content/zotero/xpcom/sync/syncRunner.js | 24 ++++++------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/chrome/content/zotero/xpcom/sync/syncRunner.js b/chrome/content/zotero/xpcom/sync/syncRunner.js index 2a3bdf527..34ac2f482 100644 --- a/chrome/content/zotero/xpcom/sync/syncRunner.js +++ b/chrome/content/zotero/xpcom/sync/syncRunner.js @@ -48,13 +48,6 @@ Zotero.Sync.Runner_Module = function (options = {}) { this.caller = new ConcurrentCaller(4); this.caller.setLogger(msg => Zotero.debug(msg)); this.caller.stopOnError = stopOnError; - this.caller.onError = function (e) { - this.addError(e); - if (e.fatal) { - this.caller.stop(); - throw e; - } - }.bind(this); var _enabled = false; var _autoSyncTimer; @@ -96,16 +89,6 @@ Zotero.Sync.Runner_Module = function (options = {}) { // Clear message list _errors = []; - if (Zotero.HTTP.browserIsOffline()){ - this.clearSyncTimeout(); // DEBUG: necessary? - var msg = Zotero.getString('general.browserIsOffline', Zotero.appName); - var e = new Zotero.Error(msg, 0, { dialogButtonText: null }) - Components.utils.reportError(e); - Zotero.debug(e, 1); - this.updateIcons(e); - return false; - } - // Shouldn't be possible if (_syncInProgress) { let msg = Zotero.getString('sync.error.syncInProgress'); @@ -213,6 +196,13 @@ Zotero.Sync.Runner_Module = function (options = {}) { } } catch (e) { + if (e instanceof Zotero.HTTP.BrowserOfflineException) { + let msg = Zotero.getString('general.browserIsOffline', Zotero.appName); + e = new Zotero.Error(msg, 0, { dialogButtonText: null }) + Zotero.logError(e); + _errors = []; + } + if (e instanceof Zotero.Sync.UserCancelledException) { Zotero.debug("Sync was cancelled"); }