From 34aa6f3698ae7f1f4ad22b89bae07cb2a88a6f8e Mon Sep 17 00:00:00 2001 From: Sainan <63328889+Sainan@users.noreply.github.com> Date: Wed, 5 Nov 2025 16:52:42 +0100 Subject: [PATCH] chore(webui): inform the user of JSON parsing errors during import --- static/webui/script.js | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/static/webui/script.js b/static/webui/script.js index 200bc040..8c88a69a 100644 --- a/static/webui/script.js +++ b/static/webui/script.js @@ -3552,16 +3552,21 @@ function doPopArchonCrystalUpgrade(type) { function doImport() { revalidateAuthz().then(() => { - $.post({ - url: "/custom/import?" + window.authz, - contentType: "application/json", - data: JSON.stringify({ - inventory: JSON.parse($("#import-inventory").val()) - }) - }).then(function () { - toast(loc("code_succImport")); - updateInventory(); - }); + try { + $.post({ + url: "/custom/import?" + window.authz, + contentType: "application/json", + data: JSON.stringify({ + inventory: JSON.parse($("#import-inventory").val()) + }) + }).then(function () { + toast(loc("code_succImport")); + updateInventory(); + }); + } catch (e) { + toast(e); + console.error(e); + } }); } -- 2.49.1