diff --git a/InvenTree/templates/js/forms.js b/InvenTree/templates/js/forms.js index cb505c2a11..68eda4b734 100644 --- a/InvenTree/templates/js/forms.js +++ b/InvenTree/templates/js/forms.js @@ -532,10 +532,49 @@ function submitFormData(fields, options) { error: function(xhr, status, thrownError) { switch (xhr.status) { - case 400: // Bad request + case 400: // Bad request handleFormErrors(xhr.responseJSON, fields, options); break; + case 0: // No response + $(options.modal).modal('hide'); + showAlertDialog( + '{% trans "No Response" %}', + '{% trans "No response from the InvenTree server" %}', + ); + break; + case 401: // Not authenticated + $(options.modal).modal('hide'); + showAlertDialog( + '{% trans "Error 401: Not Authenticated" %}', + '{% trans "Authentication credentials not supplied" %}', + ); + break; + case 403: // Permission denied + $(options.modal).modal('hide'); + showAlertDialog( + '{% trans "Error 403: Permission Denied" %}', + '{% trans "You do not have the required permissions to access this function" %}', + ); + break; + case 404: // Resource not found + $(options.modal).modal('hide'); + showAlertDialog( + '{% trans "Error 404: Resource Not Found" %}', + '{% trans "The requested resource could not be located on the server" %}', + ); + break; + case 408: // Timeout + $(options.modal).modal('hide'); + showAlertDialog( + '{% trans "Error 408: Timeout" %}', + '{% trans "Connection timeout while requesting data from server" %}', + ); + break; default: + $(options.modal).modal('hide'); + + showAlertDialog('{% trans "Error requesting form data" %}', renderErrorMessage(xhr)); + console.log(`WARNING: Unhandled response code - ${xhr.status}`); break; }