forked from mirrors/easyappointments
The generic error handler callback can now display non-JSON responses (#836).
This commit is contained in:
parent
4f1c39b564
commit
8f1e82019f
1 changed files with 8 additions and 2 deletions
|
@ -301,7 +301,13 @@ window.GeneralFunctions = window.GeneralFunctions || {};
|
||||||
exports.ajaxFailureHandler = function (jqXHR, textStatus, errorThrown) {
|
exports.ajaxFailureHandler = function (jqXHR, textStatus, errorThrown) {
|
||||||
console.error('Unexpected HTTP Error: ', jqXHR, textStatus, errorThrown);
|
console.error('Unexpected HTTP Error: ', jqXHR, textStatus, errorThrown);
|
||||||
|
|
||||||
var response = JSON.parse(jqXHR.responseText);
|
var response;
|
||||||
|
|
||||||
|
try {
|
||||||
|
response = JSON.parse(jqXHR.responseText); // JSON response
|
||||||
|
} catch(error) {
|
||||||
|
response = { message: jqXHR.responseText }; // String response
|
||||||
|
}
|
||||||
|
|
||||||
if (!response) {
|
if (!response) {
|
||||||
return;
|
return;
|
||||||
|
@ -311,7 +317,7 @@ window.GeneralFunctions = window.GeneralFunctions || {};
|
||||||
|
|
||||||
$('<div/>', {
|
$('<div/>', {
|
||||||
'class': 'well',
|
'class': 'well',
|
||||||
'text': response.message
|
'html': response.message || '→ No error information provided.'
|
||||||
})
|
})
|
||||||
.appendTo('#message_box');
|
.appendTo('#message_box');
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue