From 65138b64fc20e99d6ec3db2664febf51fc8c318d Mon Sep 17 00:00:00 2001 From: Sainan <63328889+Sainan@users.noreply.github.com> Date: Wed, 5 Nov 2025 07:58:25 -0800 Subject: [PATCH] chore(webui): inform the user of JSON parsing errors during import (#3001) Closes #2996 Reviewed-on: https://www.onlyg.it/OpenWF/SpaceNinjaServer/pulls/3001 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com> --- 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); + } }); }