From 1fd549c9c4c00d34a132b5d8746064245d4c3772 Mon Sep 17 00:00:00 2001 From: Mandragorat Wandystanu Date: Thu, 16 Nov 2017 15:31:15 +0100 Subject: static/js/app.js: Display error description returned by upload.php even if it returns status code other than 200 OK. --- static/js/app.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'static') diff --git a/static/js/app.js b/static/js/app.js index 3cdc6d7..8f4146f 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -94,8 +94,8 @@ document.addEventListener('DOMContentLoaded', function() { row.appendChild(url); var link = document.createElement('a'); + var response = JSON.parse(xhr.responseText); if (respStatus === 200) { - var response = JSON.parse(xhr.responseText); if (response.success) { link.textContent = response.files[0].url.replace(/.*?:\/\//g, ''); link.href = response.files[0].url; @@ -131,7 +131,12 @@ document.addEventListener('DOMContentLoaded', function() { link.textContent = 'File too big!'; url.appendChild(link); } else { - link.textContent = 'Server error!'; + try { + var response = JSON.parse(xhr.responseText); + link.textContent = 'Error: ' + response.description; + } catch (e) { + link.textContent = 'Server error!'; + } url.appendChild(link); } } -- cgit v1.2.3