Merge pull request #1053 from SchrodingersGat/modal-errors

Modal errors
This commit is contained in:
Oliver 2020-10-19 22:19:10 +11:00 committed by GitHub
commit 416cfb99da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -354,7 +354,7 @@ function renderErrorMessage(xhr) {
var html = '<b>' + xhr.statusText + '</b><br>';
html += '<b>Status Code - ' + xhr.status + '</b><br><hr>';
html += '<b>Error Code - ' + xhr.status + '</b><br><hr>';
html += `
<div class='panel-group'>
@ -811,16 +811,37 @@ function launchModalForm(url, options = {}) {
$(modal).modal('hide');
// Permission denied!
if (xhr.status == 403) {
if (xhr.status == 400) {
showAlertDialog(
"Permission Denied",
"Error 400: Bad Request",
"Server returned error code 400"
);
} else if (xhr.status == 401) {
showAlertDialog(
"Error 401: Not Authenticated",
"Authentication credentials not supplied"
);
} else if (xhr.status == 403) {
showAlertDialog(
"Error 403: Permission Denied",
"You do not have the required permissions to access this function"
);
return;
} else if (xhr.status == 404) {
showAlertDialog(
"Error 404: Resource Not Found",
"The requested resource could not be located on the server"
);
} else if (xhr.status == 408) {
showAlertDialog(
"Error 408: Timeout",
"Connection timeout while requesting data from server"
);
} else {
showAlertDialog('Error requesting form data', renderErrorMessage(xhr));
}
showAlertDialog('Error requesting form data', renderErrorMessage(xhr));
console.log("Modal form error: " + xhr.status);
console.log("Message: " + xhr.responseText);
}
};