From 396b7dba73d5b79c16b03557ce58b29cffa51261 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 19 Oct 2020 16:42:53 +1100 Subject: [PATCH] Extra error information when a modal dialog fails --- .../static/script/inventree/modals.js | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/InvenTree/InvenTree/static/script/inventree/modals.js b/InvenTree/InvenTree/static/script/inventree/modals.js index 80ada1596f..e2222f45c3 100644 --- a/InvenTree/InvenTree/static/script/inventree/modals.js +++ b/InvenTree/InvenTree/static/script/inventree/modals.js @@ -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); } };