Display nicer file sync error messages hiding technical details and suggesting retrying of the sync -- this should reduce unnecessary error reports for intermittent errors (e.g., network glitches)
This commit is contained in:
parent
4adc606c48
commit
ad2122a0cd
|
@ -50,6 +50,11 @@ Zotero.Sync.Storage = new function () {
|
|||
this.ERROR_NOT_ALLOWED = -14;
|
||||
this.ERROR_UNKNOWN = -15;
|
||||
|
||||
// TEMP
|
||||
// TODO: localize
|
||||
this.defaultError = "A file sync error occurred. Please try syncing again.\n\nIf the error persists, submit an error report and post the Report ID to a new thread in the Zotero Forums (forums.zotero.org).";
|
||||
this.defaultErrorRestart = "A file sync error occurred. Please restart Firefox and try syncing again.\n\nIf the error persists, submit an error report and post the Report ID to a new thread in the Zotero Forums (forums.zotero.org).";
|
||||
|
||||
//
|
||||
// Public properties
|
||||
//
|
||||
|
@ -1447,7 +1452,12 @@ Zotero.Sync.Storage = new function () {
|
|||
|
||||
Zotero.DB.rollbackAllTransactions();
|
||||
|
||||
Zotero.debug(e, 1);
|
||||
if (e) {
|
||||
Zotero.debug(e, 1);
|
||||
}
|
||||
else {
|
||||
e = Zotero.Sync.Storage.defaultError;
|
||||
}
|
||||
|
||||
// If we get a quota error, log and continue
|
||||
if (e.error && e.error == Zotero.Error.ERROR_ZFS_OVER_QUOTA && _callbacks.onWarning) {
|
||||
|
|
|
@ -26,7 +26,12 @@
|
|||
|
||||
Zotero.Sync.Storage.Session.WebDAV = function (callbacks) {
|
||||
this.onChangesMade = callbacks.onChangesMade ? callbacks.onChangesMade : function () {};
|
||||
this.onError = callbacks.onError ? callbacks.onError : function () {};
|
||||
this.onError = callbacks.onError ? function (e) {
|
||||
if (!e) {
|
||||
e = Zotero.Sync.Storage.Session.WebDAV.prototype.defaultError;
|
||||
}
|
||||
callbacks.onError(e);
|
||||
} : function () {};
|
||||
|
||||
this._parentURI;
|
||||
this._rootURI;
|
||||
|
@ -41,6 +46,12 @@ Zotero.Sync.Storage.Session.WebDAV.prototype.__defineGetter__('includeUserFiles'
|
|||
|
||||
Zotero.Sync.Storage.Session.WebDAV.prototype.includeGroupItems = false;
|
||||
|
||||
// TEMP
|
||||
// TODO: localize
|
||||
Zotero.Sync.Storage.Session.WebDAV.prototype.defaultError = "A WebDAV file sync error occurred. Please try syncing again.\n\nIf the error persists, submit an error report and post the Report ID to a new thread in the Zotero Forums (forums.zotero.org).";
|
||||
Zotero.Sync.Storage.Session.WebDAV.prototype.defaultErrorRestart = "A WebDAV file sync error occurred. Please restart Firefox and try syncing again.\n\nIf the error persists, submit an error report and post the Report ID to a new thread in the Zotero Forums (forums.zotero.org).";
|
||||
|
||||
|
||||
Zotero.Sync.Storage.Session.WebDAV.prototype.__defineGetter__('enabled', function () {
|
||||
return this.includeUserFiles;
|
||||
});
|
||||
|
@ -277,12 +288,12 @@ Zotero.Sync.Storage.Session.WebDAV.prototype._getStorageModificationTime = funct
|
|||
|
||||
// Delete invalid .prop files
|
||||
if (invalid) {
|
||||
var msg = "An error occurred during file syncing. Try the sync again.\n\n"
|
||||
+ "Invalid mod date '" + Zotero.Utilities.prototype.ellipsize(mtime, 20)
|
||||
var msg = "Invalid mod date '" + Zotero.Utilities.prototype.ellipsize(mtime, 20)
|
||||
+ "' for item " + Zotero.Items.getLibraryKeyHash(item);
|
||||
Zotero.debug(msg, 1);
|
||||
Components.utils.reportError(msg);
|
||||
self._deleteStorageFiles([item.key + ".prop"], null, self);
|
||||
self.onError(msg);
|
||||
self.onError();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -408,8 +419,11 @@ Zotero.Sync.Storage.Session.WebDAV.prototype.downloadFile = function (request) {
|
|||
return;
|
||||
}
|
||||
else if (status != 200) {
|
||||
self.onError("Unexpected status code " + status
|
||||
+ " for request " + data.request.name + " in Zotero.Sync.Storage.Session.WebDAV.downloadFile()");
|
||||
var msg = "Unexpected status code " + status
|
||||
+ " for request " + data.request.name + " in Zotero.Sync.Storage.Session.WebDAV.downloadFile()";
|
||||
Zotero.debug(msg, 1);
|
||||
Components.utils.reportError(msg);
|
||||
self.onError();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -620,6 +634,7 @@ Zotero.Sync.Storage.Session.WebDAV.prototype._onUploadComplete = function (httpR
|
|||
break;
|
||||
|
||||
case 403:
|
||||
case 500:
|
||||
this.onError(Zotero.localeJoin([
|
||||
Zotero.getString('sync.storage.error.fileUploadFailed'),
|
||||
Zotero.getString('sync.storage.error.checkFileSyncSettings')
|
||||
|
@ -696,8 +711,11 @@ Zotero.Sync.Storage.Session.WebDAV.prototype.getLastSyncTime = function (callbac
|
|||
self._checkResponse(req, self);
|
||||
|
||||
if (req.status != 200) {
|
||||
self.onError("Unexpected status code " + req.status + " caching "
|
||||
+ "authentication credentials in Zotero.Sync.Storage.Session.WebDAV.getLastSyncTime()");
|
||||
var msg = "Unexpected status code " + req.status + " caching "
|
||||
+ "authentication credentials in Zotero.Sync.Storage.Session.WebDAV.getLastSyncTime()";
|
||||
Zotero.debug(msg, 1);
|
||||
Components.utils.reportError(msg);
|
||||
self.onError(Zotero.Sync.Storage.Session.WebDAV.prototype.defaultErrorRestart);
|
||||
return;
|
||||
}
|
||||
self._cachedCredentials = true;
|
||||
|
@ -718,9 +736,17 @@ Zotero.Sync.Storage.Session.WebDAV.prototype.getLastSyncTime = function (callbac
|
|||
}
|
||||
Zotero.debug(req.status);
|
||||
|
||||
if (req.status == 403) {
|
||||
Zotero.debug("Clearing WebDAV authentication credentials", 2);
|
||||
self._cachedCredentials = false;
|
||||
}
|
||||
|
||||
if (req.status != 200 && req.status != 404) {
|
||||
self.onError("Unexpected status code " + req.status + " getting "
|
||||
+ "last file sync time");
|
||||
var msg = "Unexpected status code " + req.status + " getting "
|
||||
+ "last file sync time";
|
||||
Zotero.debug(msg, 1);
|
||||
Components.utils.reportError(msg);
|
||||
self.onError();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -119,11 +119,13 @@ Zotero.Sync.Storage.Session.ZFS.prototype._getStorageFileInfo = function (item,
|
|||
return;
|
||||
}
|
||||
else if (req.status != 200) {
|
||||
var msg = "Unexpected status code " + req.status + " in " + funcName;
|
||||
Zotero.debug(msg + " (" + Zotero.Items.getLibraryKeyHash(item) + ")", 1);
|
||||
var msg = "Unexpected status code " + req.status + " in " + funcName
|
||||
+ " (" + Zotero.Items.getLibraryKeyHash(item) + ")";
|
||||
Zotero.debug(msg, 1);
|
||||
Zotero.debug(req.responseText);
|
||||
Zotero.debug(req.getAllResponseHeaders());
|
||||
self.onError(msg);
|
||||
Components.utils.reportError(msg);
|
||||
self.onError();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -250,15 +252,18 @@ Zotero.Sync.Storage.Session.ZFS.prototype.downloadFile = function (request) {
|
|||
},
|
||||
onStop: function (request, status, response, data) {
|
||||
if (status != 200) {
|
||||
self.onError("Unexpected status code " + status
|
||||
+ " for request " + data.request.name + " in Zotero.Sync.Storage.Session.ZFS.downloadFile()");
|
||||
var msg = "Unexpected status code " + status
|
||||
+ " for request " + data.request.name + " in Zotero.Sync.Storage.Session.ZFS.downloadFile()";
|
||||
Zotero.debug(msg, 1);
|
||||
Components.utils.reportError(msg);
|
||||
self.onError();
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't try to process if the request has been cancelled
|
||||
if (data.request.isFinished()) {
|
||||
Zotero.debug("Download request " + data.request.name
|
||||
+ " is no longer running after file download");
|
||||
+ " is no longer running after file download", 2);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -526,11 +531,13 @@ Zotero.Sync.Storage.Session.ZFS.prototype._getFileUploadParameters = function (i
|
|||
return;
|
||||
}
|
||||
else if (req.status != 200) {
|
||||
var msg = "Unexpected status code " + req.status + " in " + funcName;
|
||||
Zotero.debug(msg + " (" + Zotero.Items.getLibraryKeyHash(item) + ")", 1);
|
||||
var msg = "Unexpected status code " + req.status + " in " + funcName
|
||||
+ " (" + Zotero.Items.getLibraryKeyHash(item) + ")";
|
||||
Zotero.debug(msg, 1);
|
||||
Zotero.debug(req.responseText);
|
||||
Zotero.debug(req.getAllResponseHeaders());
|
||||
self.onError(msg);
|
||||
Components.utils.reportError(msg);
|
||||
self.onError();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -700,8 +707,12 @@ Zotero.Sync.Storage.Session.ZFS.prototype._onUploadComplete = function (httpRequ
|
|||
return;
|
||||
|
||||
default:
|
||||
this.onError("Unexpected file upload status " + status
|
||||
+ " in Zotero.Sync.Storage._onUploadComplete()");
|
||||
var msg = "Unexpected file upload status " + status
|
||||
+ " in Zotero.Sync.Storage._onUploadComplete()"
|
||||
+ " (" + Zotero.Items.getLibraryKeyHash(item) + ")";
|
||||
Zotero.debug(msg, 1);
|
||||
Components.utils.reportError(msg);
|
||||
this.onError();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -714,11 +725,13 @@ Zotero.Sync.Storage.Session.ZFS.prototype._onUploadComplete = function (httpRequ
|
|||
Zotero.Utilities.HTTP.doPost(uri, body, function (req) {
|
||||
if (req.status != 204) {
|
||||
var msg = "Unexpected file registration status " + req.status
|
||||
+ " in Zotero.Sync.Storage._onUploadComplete()";
|
||||
Zotero.debug(msg + " (" + Zotero.Items.getLibraryKeyHash(item) + ")", 1);
|
||||
+ " in Zotero.Sync.Storage._onUploadComplete()"
|
||||
+ " (" + Zotero.Items.getLibraryKeyHash(item) + ")";
|
||||
Zotero.debug(msg, 1);
|
||||
Zotero.debug(req.responseText);
|
||||
Zotero.debug(req.getAllResponseHeaders());
|
||||
self.onError(msg);
|
||||
Components.utils.reportError(msg);
|
||||
self.onError();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -795,8 +808,11 @@ Zotero.Sync.Storage.Session.ZFS.prototype.getLastSyncTime = function (callback)
|
|||
uri.spec += "?auth=1";
|
||||
Zotero.Utilities.HTTP.doHead(uri, function (req) {
|
||||
if (req.status != 200) {
|
||||
self.onError("Unexpected status code " + req.status + " caching "
|
||||
+ "authentication credentials in Zotero.Sync.Storage.Session.ZFS.getLastSyncTime()");
|
||||
var msg = "Unexpected status code " + req.status + " caching "
|
||||
+ "authentication credentials in Zotero.Sync.Storage.Session.ZFS.getLastSyncTime()";
|
||||
Zotero.debug(msg, 1);
|
||||
Components.utils.reportError(msg);
|
||||
self.onError(Zotero.Sync.Storage.defaultErrorRestart);
|
||||
return;
|
||||
}
|
||||
self._cachedCredentials = true;
|
||||
|
@ -811,9 +827,17 @@ Zotero.Sync.Storage.Session.ZFS.prototype.getLastSyncTime = function (callback)
|
|||
}
|
||||
Zotero.debug(req.status);
|
||||
|
||||
if (req.status == 403) {
|
||||
Zotero.debug("Clearing ZFS authentication credentials", 2);
|
||||
self._cachedCredentials = false;
|
||||
}
|
||||
|
||||
if (req.status != 200 && req.status != 404) {
|
||||
self.onError("Unexpected status code " + req.status + " getting "
|
||||
+ "last file sync time");
|
||||
var msg = "Unexpected status code " + req.status + " getting "
|
||||
+ "last file sync time";
|
||||
Zotero.debug(msg, 1);
|
||||
Components.utils.reportError(msg);
|
||||
self.onError();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -865,8 +889,11 @@ Zotero.Sync.Storage.Session.ZFS.prototype.setLastSyncTime = function (callback,
|
|||
Zotero.debug(req.status);
|
||||
|
||||
if (req.status != 200) {
|
||||
self.onError("Unexpected status code " + req.status + " setting "
|
||||
+ "last file sync time");
|
||||
var msg = "Unexpected status code " + req.status + " setting "
|
||||
+ "last file sync time";
|
||||
Zotero.debug(msg, 1);
|
||||
Components.utils.reportError(msg);
|
||||
self.onError();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user