From 658a2edef2dc36dbd1811ef5c033df08e494e4a1 Mon Sep 17 00:00:00 2001 From: Ihsan Ullah Date: Sat, 12 Oct 2024 22:42:38 +0500 Subject: [PATCH] handled submission file_name too long error and fixed the previous error handling that was causing screen freezing --- .../competitions/detail/submission_upload.tag | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/static/riot/competitions/detail/submission_upload.tag b/src/static/riot/competitions/detail/submission_upload.tag index 49fe64f01..7df267a2b 100644 --- a/src/static/riot/competitions/detail/submission_upload.tag +++ b/src/static/riot/competitions/detail/submission_upload.tag @@ -476,19 +476,29 @@ .fail(function (response) { if (response) { try { - let errors = JSON.parse(response.responseText); + let errors = JSON.parse(response.responseText) // Clean up errors to not be arrays but plain text Object.keys(errors).map(function (key, index) { errors[key] = errors[key].join('; ') }) + // Create a string to concatenate all error messages + let errorMessages = "Error in submission upload:\n" + Object.keys(errors).forEach(function (key) { + errorMessages += key + ": " + errors[key] + "\n" + }) + + toastr.error(errorMessages) self.update({errors: errors}) - } catch (e) { + } catch (e) { + toastr.error("Error in submission upload\n"+e) } + } else { + toastr.error("Something went wrong, please try again later") } - toastr.error(`Creation failed, error occurred: ${response.responseJSON.data_file[0]}`) + }) .always(function () { setTimeout(self.hide_progress_bar, 500)