From 5e9f4a24c890ea34a762380ac01d76648a8547e5 Mon Sep 17 00:00:00 2001 From: Robert Kaiser Date: Mon, 20 Nov 2017 19:26:09 +0100 Subject: [PATCH] improve error handling, actually print the error message if one is sent --- js/ui.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/js/ui.js b/js/ui.js index f451fbe..263a139 100644 --- a/js/ui.js +++ b/js/ui.js @@ -527,21 +527,31 @@ function uploadTrack() { if (aStatusCode >= 400) { reportUploadStatus(false, aResult); } - else { + else if (aResult["id"]) { reportUploadStatus(true); } + else { // If no ID is returned, we assume a general error. + reportUploadStatus(false); + } } ); } -function reportUploadStatus(aSuccess, aMessage) { +function reportUploadStatus(aSuccess, aResponse) { document.getElementById("uploadStatusCloseButton").disabled = false; document.getElementById("uploadInProgress").style.display = "none"; if (aSuccess) { document.getElementById("uploadSuccess").style.display = "block"; } - else if (aMessage) { - document.getElementById("uploadErrorMsg").textContent = aMessage; + else if (aResponse["message"]) { + document.getElementById("uploadErrorMsg").textContent = aResponse["message"]; + if (aResponse["errortype"]) { + document.getElementById("uploadErrorMsg").textContent += " (" + aResponse["errortype"] + ")"; + } + document.getElementById("uploadError").style.display = "block"; + } + else if (aResponse) { + document.getElementById("uploadErrorMsg").textContent = aResponse; document.getElementById("uploadError").style.display = "block"; } else { -- 2.43.0