Merge pull request #14083 from edx/fix-unformatted-403

fix unformatted html in studio error response
This commit is contained in:
Ari Rizzitano
2016-12-16 11:08:19 -05:00
committed by GitHub

View File

@@ -25,23 +25,24 @@
dataType: 'json'
});
$(document).ajaxError(function(event, jqXHR, ajaxSettings) {
var message, msg;
var msg, contentType,
message = gettext('This may be happening because of an error with our server or your internet connection. Try refreshing the page or making sure you are online.'); // eslint-disable-line max-len
if (ajaxSettings.notifyOnError === false) {
return;
}
if (jqXHR.responseText) {
try {
message = JSON.parse(jqXHR.responseText).error;
} catch (error) {
message = str.truncate(jqXHR.responseText, 300);
}
} else {
message = gettext('This may be happening because of an error with our server or your internet connection. Try refreshing the page or making sure you are online.'); // eslint-disable-line max-len
contentType = jqXHR.getResponseHeader('content-type');
if (contentType && contentType.indexOf('json') > -1 && jqXHR.responseText) {
message = JSON.parse(jqXHR.responseText).error;
}
msg = new NotificationView.Error({
'title': gettext("Studio's having trouble saving your work"),
'message': message
});
console.log('Studio AJAX Error', { // eslint-disable-line no-console
url: event.currentTarget.URL,
response: jqXHR.responseText,
status: jqXHR.status
});
return msg.show();
});
$.postJSON = function(url, data, callback) {