Properly handle errors (including 500)

Signed-off-by: Tomasz Grobelny <tomasz@grobelny.net>
This commit is contained in:
Tomasz Grobelny 2018-11-15 17:51:03 +01:00
parent 1f6f276fa0
commit 8e240d1197
2 changed files with 9 additions and 2 deletions

View File

@ -2250,6 +2250,10 @@
return this.reportOperationProgress(fileNames, moveFileFunction, callback); return this.reportOperationProgress(fileNames, moveFileFunction, callback);
}, },
_reflect: function (promise){
return promise.then(function(v){ return {}}, function(e){ return {}});
},
reportOperationProgress: function (fileNames, operationFunction, callback){ reportOperationProgress: function (fileNames, operationFunction, callback){
var self = this; var self = this;
self._operationProgressBar.showProgressBar(false); self._operationProgressBar.showProgressBar(false);
@ -2257,7 +2261,7 @@
var counter = 0; var counter = 0;
var promises = _.map(fileNames, function(arg) { var promises = _.map(fileNames, function(arg) {
return mcSemaphore.acquire().then(function(){ return mcSemaphore.acquire().then(function(){
return operationFunction(arg).then(function(){ return operationFunction(arg).always(function(){
mcSemaphore.release(); mcSemaphore.release();
counter++; counter++;
self._operationProgressBar.setProgressBarValue(100.0*counter/fileNames.length); self._operationProgressBar.setProgressBarValue(100.0*counter/fileNames.length);
@ -2265,7 +2269,7 @@
}); });
}); });
return Promise.all(promises).then(function(){ return Promise.all(_.map(promises, self._reflect)).then(function(){
if (callback) { if (callback) {
callback(); callback();
} }

View File

@ -427,6 +427,9 @@
_getSabreException: function(response) { _getSabreException: function(response) {
var result = {}; var result = {};
var xml = response.xhr.responseXML; var xml = response.xhr.responseXML;
if (xml === null) {
return result;
}
var messages = xml.getElementsByTagNameNS('http://sabredav.org/ns', 'message'); var messages = xml.getElementsByTagNameNS('http://sabredav.org/ns', 'message');
var exceptions = xml.getElementsByTagNameNS('http://sabredav.org/ns', 'exception'); var exceptions = xml.getElementsByTagNameNS('http://sabredav.org/ns', 'exception');
if (messages.length) { if (messages.length) {