From 9fe3cc213a04b5686cb0d05824e4c68d46a63afe Mon Sep 17 00:00:00 2001 From: Deimos Date: Wed, 29 May 2019 12:40:06 -0600 Subject: [PATCH] Intercooler: Display custom message for 413 error Since a 413 error (Payload Too Large) is returned from nginx and doesn't even reach the app, we need to handle this in the javascript instead of the normal method of returning a custom error response. --- tildes/static/js/scripts.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tildes/static/js/scripts.js b/tildes/static/js/scripts.js index 9ef0c79..0504903 100644 --- a/tildes/static/js/scripts.js +++ b/tildes/static/js/scripts.js @@ -59,7 +59,12 @@ $(document).on('complete.ic', function(evt, elt, data, status, xhr, requestId) { if (status === 'success') { $statusElement.addClass('form-status-success').text('Saved successfully'); } else { - $statusElement.addClass('form-status-error').text(xhr.responseText); + if (xhr.status === 413) { + errorText = "Too much data submitted"; + } else { + errorText = xhr.responseText; + } + $statusElement.addClass('form-status-error').text(errorText); } $statusElement.fadeIn('slow'); });