Better sync/storage error handling
This commit is contained in:
parent
12fdfe7dc4
commit
0cece91741
2 changed files with 13 additions and 15 deletions
|
@ -1092,7 +1092,7 @@ Zotero.Sync.Storage = new function () {
|
||||||
if (destFile.exists()) {
|
if (destFile.exists()) {
|
||||||
var msg = "ZIP entry '" + fileName + "' "
|
var msg = "ZIP entry '" + fileName + "' "
|
||||||
+ " already exists";
|
+ " already exists";
|
||||||
Zotero.debug(msg);
|
Zotero.debug(msg, 2);
|
||||||
Components.utils.reportError(msg + " in " + funcName);
|
Components.utils.reportError(msg + " in " + funcName);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1117,8 +1117,11 @@ Zotero.Sync.Storage = new function () {
|
||||||
var file = item.getFile();
|
var file = item.getFile();
|
||||||
if (!file) {
|
if (!file) {
|
||||||
_removeRequest(request);
|
_removeRequest(request);
|
||||||
|
var msg = "File not found for item " + item.id + " after extracting ZIP";
|
||||||
|
Zotero.debug(msg, 1);
|
||||||
|
Components.utils.reportError(msg + " in " + funcName);
|
||||||
_queueAdvance('download', Zotero.Sync.Storage.downloadFile, true);
|
_queueAdvance('download', Zotero.Sync.Storage.downloadFile, true);
|
||||||
_error("File not found for item " + item.id + " after extracting ZIP");
|
return;
|
||||||
}
|
}
|
||||||
file.lastModifiedTime = syncModTime * 1000;
|
file.lastModifiedTime = syncModTime * 1000;
|
||||||
|
|
||||||
|
@ -1918,17 +1921,17 @@ Zotero.Sync.Storage = new function () {
|
||||||
* @throws
|
* @throws
|
||||||
*/
|
*/
|
||||||
function _checkResponse(req) {
|
function _checkResponse(req) {
|
||||||
|
if (!req.responseText) {
|
||||||
|
_error('Empty response from server');
|
||||||
|
}
|
||||||
if (!req.responseXML ||
|
if (!req.responseXML ||
|
||||||
!req.responseXML.firstChild ||
|
!req.responseXML.firstChild ||
|
||||||
!(req.responseXML.firstChild.namespaceURI == 'DAV:' &&
|
!(req.responseXML.firstChild.namespaceURI == 'DAV:' &&
|
||||||
req.responseXML.firstChild.localName == 'multistatus')) {
|
req.responseXML.firstChild.localName == 'multistatus') ||
|
||||||
|
!req.responseXML.childNodes[0].firstChild) {
|
||||||
Zotero.debug(req.responseText);
|
Zotero.debug(req.responseText);
|
||||||
_error('Invalid response from storage server');
|
_error('Invalid response from storage server');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!req.responseXML.childNodes[0].firstChild) {
|
|
||||||
_error('Empty response from storage server');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1154,15 +1154,11 @@ Zotero.Sync.Server = new function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!xmlhttp.responseXML || !xmlhttp.responseXML.childNodes[0] ||
|
if (!xmlhttp.responseXML || !xmlhttp.responseXML.childNodes[0] ||
|
||||||
xmlhttp.responseXML.childNodes[0].tagName != 'response') {
|
xmlhttp.responseXML.childNodes[0].tagName != 'response' ||
|
||||||
|
!xmlhttp.responseXML.childNodes[0].firstChild) {
|
||||||
Zotero.debug(xmlhttp.responseText);
|
Zotero.debug(xmlhttp.responseText);
|
||||||
_error('Invalid response from server', xmlhttp.responseText);
|
_error('Invalid response from server', xmlhttp.responseText);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!xmlhttp.responseXML.childNodes[0].firstChild) {
|
|
||||||
Zotero.debug(xmlhttp.responseText);
|
|
||||||
_error('Empty response from server');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1184,8 +1180,7 @@ Zotero.Sync.Server = new function () {
|
||||||
function _error(e, extraInfo) {
|
function _error(e, extraInfo) {
|
||||||
if (extraInfo) {
|
if (extraInfo) {
|
||||||
// Server errors will generally be HTML
|
// Server errors will generally be HTML
|
||||||
var ZU = new Zotero.Utilities;
|
extraInfo = Zotero.Utilities.prototype.unescapeHTML(extraInfo);
|
||||||
extraInfo = ZU.unescapeHTML(extraInfo);
|
|
||||||
Components.utils.reportError(extraInfo);
|
Components.utils.reportError(extraInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue