Properly handle errors thrown by merge window, including cases of "Source item for keyed source doesn't exist in Zotero.Item.getSource()"

This commit is contained in:
Dan Stillman 2009-09-27 02:00:08 +00:00
parent 0974d4bcf3
commit 38459c5d0e
2 changed files with 17 additions and 16 deletions

View file

@ -46,8 +46,9 @@ var Zotero_Merge_Window = new function () {
break;
default:
throw ("Unsupported merge object type '" + _mergeGroup.type
_error("Unsupported merge object type '" + _mergeGroup.type
+ "' in Zotero_Merge_Window.init()");
return;
}
_mergeGroup.leftCaption = _io.dataIn.captions[0];
@ -128,13 +129,8 @@ var Zotero_Merge_Window = new function () {
}
}
catch (e) {
Zotero.debug(e);
var prompt = Components.classes["@mozilla.org/network/default-prompt;1"]
.createInstance(Components.interfaces.nsIPrompt);
prompt.alert(Zotero.getString('general.error'), e);
_wizard.getButton('cancel').click();
return false;
_error(e);
return;
}
if (_mergeGroup.type == 'item') {
@ -203,8 +199,9 @@ var Zotero_Merge_Window = new function () {
// Hack to support creator reconciliation via item view
function _updateChangedCreators() {
if (_mergeGroup.type != 'item') {
throw ("_updateChangedCreators called on non-item object in "
_error("_updateChangedCreators called on non-item object in "
+ "Zotero_Merge_Window._updateChangedCreators()");
return;
}
if (_io.dataIn.changedCreators) {
@ -228,4 +225,11 @@ var Zotero_Merge_Window = new function () {
}
}
}
function _error(e) {
Zotero.debug(e);
_io.error = e;
_wizard.getButton('cancel').click();
}
}

View file

@ -144,10 +144,6 @@ Zotero.Sync = new function() {
}
// Last sync time is before start of log
Zotero.debug('==============');
Zotero.debug(lastSyncDate);
Zotero.debug(lastSyncDate + '');
Zotero.debug(syncLogStart);
if (lastSyncDate && new Date(syncLogStart * 1000) > lastSyncDate) {
return -1;
}
@ -2668,9 +2664,8 @@ Zotero.Sync.Server.Data = new function() {
var mergeData = _reconcile(type, toReconcile, remoteCreatorStore);
if (!mergeData) {
// TODO: throw?
Zotero.DB.rollbackTransaction();
return false;
throw ("Merge error");
}
_processMergeData(
syncSession,
@ -3205,7 +3200,9 @@ Zotero.Sync.Server.Data = new function() {
.getService(Components.interfaces.nsIWindowMediator);
var lastWin = wm.getMostRecentWindow("navigator:browser");
lastWin.openDialog('chrome://zotero/content/merge.xul', '', 'chrome,modal,centerscreen', io);
if (io.error) {
throw (io.error);
}
return io.dataOut;
}