From 010c0bfc7ddf44111903239e9ad307e66147ec4d Mon Sep 17 00:00:00 2001 From: Ozzie Isaacs Date: Sun, 16 May 2021 14:07:16 +0200 Subject: [PATCH] Improved error handling for content too long --- cps/static/js/uploadprogress.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cps/static/js/uploadprogress.js b/cps/static/js/uploadprogress.js index be987437..1a79eb35 100644 --- a/cps/static/js/uploadprogress.js +++ b/cps/static/js/uploadprogress.js @@ -124,15 +124,24 @@ error: function(xhr) { this.$modalTitle.text(this.options.modalTitleFailed); + this.setProgress(100); this.$modalBar.removeClass("progress-bar-success"); this.$modalBar.addClass("progress-bar-danger"); this.$modalFooter.show(); var contentType = xhr.getResponseHeader("Content-Type"); // Write the error response to the document. - if (contentType || xhr.status === 422) { + if (xhr.status === 502 || xhr.status === 0) { + if (xhr.statusText) { + this.$modalBar.text(xhr.statusText + ": File size may be too big"); + } else { + this.$modalBar.text("Error: File size may be too big"); + } + + } + else if (contentType || xhr.status === 422) { var responseText = xhr.responseText; - if (contentType.indexOf("text/plain") !== -1) { + if (contentType.indexOf("text/plain") === -1) { responseText = "
" + responseText + "
"; document.write(responseText); } else {