updates #161 Proper error messages and include server response

This commit is contained in:
JC Brand 2018-04-24 10:09:45 +02:00
parent e0aaeb66ea
commit 9a410c6a96

View File

@ -151,10 +151,7 @@
'message': this.get('get') 'message': this.get('get')
}); });
} else { } else {
this.save({ xhr.onerror();
'upload': _converse.FAILURE,
'message': __('Sorry, could not succesfully upload your file')
});
} }
} }
}; };
@ -164,9 +161,14 @@
} }
}, false); }, false);
xhr.onerror = () => { xhr.onerror = () => {
let message = __('Sorry, could not succesfully upload your file.');
if (xhr.responseText) {
message += ' ' + __('Your server\'s response: "%1$s"', xhr.responseText)
}
this.save({ this.save({
'type': 'error',
'upload': _converse.FAILURE, 'upload': _converse.FAILURE,
'message': __('Sorry, could not succesfully upload your file') 'message': message
}); });
}; };
xhr.open('PUT', this.get('put'), true); xhr.open('PUT', this.get('put'), true);