Handle browser-offline error from anywhere in sync code

And don't throw from ConcurrentCaller, because it results in an
unhandled rejection
This commit is contained in:
Dan Stillman 2016-05-06 04:59:04 -04:00
parent 2894e4f462
commit 52ca6d4713

View File

@ -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");
}