commit 0cece9174170e0a68f3ddac0c4e0a015890cabac
parent 12fdfe7dc4fa901f22e31d855b048296816cf6f4
Author: Dan Stillman <dstillman@zotero.org>
Date: Sat, 8 Nov 2008 09:55:57 +0000
Better sync/storage error handling
Diffstat:
2 files changed, 13 insertions(+), 15 deletions(-)
diff --git a/chrome/content/zotero/xpcom/storage.js b/chrome/content/zotero/xpcom/storage.js
@@ -1092,7 +1092,7 @@ Zotero.Sync.Storage = new function () {
if (destFile.exists()) {
var msg = "ZIP entry '" + fileName + "' "
+ " already exists";
- Zotero.debug(msg);
+ Zotero.debug(msg, 2);
Components.utils.reportError(msg + " in " + funcName);
continue;
}
@@ -1117,8 +1117,11 @@ Zotero.Sync.Storage = new function () {
var file = item.getFile();
if (!file) {
_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);
- _error("File not found for item " + item.id + " after extracting ZIP");
+ return;
}
file.lastModifiedTime = syncModTime * 1000;
@@ -1918,17 +1921,17 @@ Zotero.Sync.Storage = new function () {
* @throws
*/
function _checkResponse(req) {
+ if (!req.responseText) {
+ _error('Empty response from server');
+ }
if (!req.responseXML ||
!req.responseXML.firstChild ||
!(req.responseXML.firstChild.namespaceURI == 'DAV:' &&
- req.responseXML.firstChild.localName == 'multistatus')) {
+ req.responseXML.firstChild.localName == 'multistatus') ||
+ !req.responseXML.childNodes[0].firstChild) {
Zotero.debug(req.responseText);
_error('Invalid response from storage server');
}
-
- if (!req.responseXML.childNodes[0].firstChild) {
- _error('Empty response from storage server');
- }
}
diff --git a/chrome/content/zotero/xpcom/sync.js b/chrome/content/zotero/xpcom/sync.js
@@ -1154,15 +1154,11 @@ Zotero.Sync.Server = new function () {
}
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);
_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) {
if (extraInfo) {
// Server errors will generally be HTML
- var ZU = new Zotero.Utilities;
- extraInfo = ZU.unescapeHTML(extraInfo);
+ extraInfo = Zotero.Utilities.prototype.unescapeHTML(extraInfo);
Components.utils.reportError(extraInfo);
}