JavaScript function for getting reasonable error message from an XHR response
This commit is contained in:
parent
766e766f50
commit
46612a9f68
@ -361,6 +361,20 @@ function getNotificationsLoop() {
|
||||
}, 30000);
|
||||
}
|
||||
|
||||
/* Returns a more-or-less reasonable message given an error response object. */
|
||||
function xhrErrorResponseMessage(err) {
|
||||
if (typeof err.responseJSON == 'undefined')
|
||||
return err.statusText;
|
||||
|
||||
if (typeof err.responseJSON._error != 'undefined' && typeof err.responseJSON._error.message != 'undefined')
|
||||
return err.responseJSON._error.message;
|
||||
|
||||
if (typeof err.responseJSON._message != 'undefined')
|
||||
return err.responseJSON._message
|
||||
|
||||
return err.statusText;
|
||||
}
|
||||
|
||||
/* Notifications: Toastr Defaults */
|
||||
toastr.options.showDuration = 50;
|
||||
toastr.options.progressBar = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user