- Fix error handling in syncing when using pumpGenerator()
- Take an optional error handler as the third parameter to pumpGenerator()
This commit is contained in:
parent
ec6d38df68
commit
01ea59491a
|
@ -1460,10 +1460,27 @@ Zotero.Sync.Server = new function () {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var errorHandler = function (e) {
|
||||||
|
Zotero.DB.rollbackTransaction();
|
||||||
|
|
||||||
|
Zotero.UnresponsiveScriptIndicator.enable();
|
||||||
|
|
||||||
|
if (progressMeter) {
|
||||||
|
Zotero.hideZoteroPaneOverlay();
|
||||||
|
}
|
||||||
|
Zotero.suppressUIUpdates = false;
|
||||||
|
_updatesInProgress = false;
|
||||||
|
|
||||||
|
_error(e);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var gen = Zotero.Sync.Server.Data.processUpdatedXML(
|
var gen = Zotero.Sync.Server.Data.processUpdatedXML(
|
||||||
xml.updated, lastLocalSyncDate, syncSession, libraryID, function (xmlstr) {
|
xml.updated,
|
||||||
try {
|
lastLocalSyncDate,
|
||||||
|
syncSession,
|
||||||
|
libraryID,
|
||||||
|
function (xmlstr) {
|
||||||
Zotero.UnresponsiveScriptIndicator.enable();
|
Zotero.UnresponsiveScriptIndicator.enable();
|
||||||
|
|
||||||
if (progressMeter) {
|
if (progressMeter) {
|
||||||
|
@ -1654,26 +1671,12 @@ Zotero.Sync.Server = new function () {
|
||||||
Zotero.HTTP.doPost(url, body, uploadCallback);
|
Zotero.HTTP.doPost(url, body, uploadCallback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e) {
|
|
||||||
_error(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
||||||
Zotero.pumpGenerator(gen);
|
Zotero.pumpGenerator(gen, false, errorHandler);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
Zotero.DB.rollbackTransaction();
|
errorHandler(e);
|
||||||
|
|
||||||
Zotero.UnresponsiveScriptIndicator.enable();
|
|
||||||
|
|
||||||
if (progressMeter) {
|
|
||||||
Zotero.hideZoteroPaneOverlay();
|
|
||||||
}
|
|
||||||
Zotero.suppressUIUpdates = false;
|
|
||||||
_updatesInProgress = false;
|
|
||||||
|
|
||||||
throw (e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
|
|
|
@ -1498,8 +1498,11 @@ const ZOTERO_CONFIG = {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pumps a generator until it yields false. See itemTreeView.js for an example.
|
* Pumps a generator until it yields false. See itemTreeView.js for an example.
|
||||||
|
*
|
||||||
|
* If errorHandler is specified, exceptions in the generator will be caught
|
||||||
|
* and passed to the callback
|
||||||
*/
|
*/
|
||||||
this.pumpGenerator = function(generator, ms) {
|
this.pumpGenerator = function(generator, ms, errorHandler) {
|
||||||
_waiting++;
|
_waiting++;
|
||||||
|
|
||||||
var timer = Components.classes["@mozilla.org/timer;1"].
|
var timer = Components.classes["@mozilla.org/timer;1"].
|
||||||
|
@ -1528,7 +1531,13 @@ const ZOTERO_CONFIG = {
|
||||||
_waitTimers = [];
|
_waitTimers = [];
|
||||||
_waitTimerCallbacks = [];
|
_waitTimerCallbacks = [];
|
||||||
|
|
||||||
if(err) throw err;
|
if(err) {
|
||||||
|
if(errorHandler) {
|
||||||
|
errorHandler(err);
|
||||||
|
} else {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
timer.initWithCallback(timerCallback, ms ? ms : 0, Components.interfaces.nsITimer.TYPE_REPEATING_SLACK);
|
timer.initWithCallback(timerCallback, ms ? ms : 0, Components.interfaces.nsITimer.TYPE_REPEATING_SLACK);
|
||||||
// add timer to global scope so that it doesn't get garbage collected before it completes
|
// add timer to global scope so that it doesn't get garbage collected before it completes
|
||||||
|
|
Loading…
Reference in New Issue
Block a user