From bc0e3bb3177d4a1982e544fb6652030e7b6a0a4f Mon Sep 17 00:00:00 2001 From: Aaron Raimist Date: Thu, 3 Jun 2021 23:39:29 -0500 Subject: [PATCH] Add warning dialog when custom config.json is invalid Signed-off-by: Aaron Raimist --- src/electron-main.js | 10 ++++++++++ src/i18n/strings/en_EN.json | 2 ++ 2 files changed, 12 insertions(+) diff --git a/src/electron-main.js b/src/electron-main.js index 3966834..f3d05b0 100644 --- a/src/electron-main.js +++ b/src/electron-main.js @@ -207,6 +207,16 @@ async function setupGlobals() { vectorConfig = Object.assign(vectorConfig, localConfig); } catch (e) { + if (e instanceof SyntaxError) { + dialog.showMessageBox({ + type: "error", + title: _t("Your %(brand)s is misconfigured", { brand: vectorConfig.brand || 'Element'}), + message: _t("Your custom %(brand)s configuration contains invalid JSON. " + + "Please correct the problem and reopen %(brand)s.", { brand: vectorConfig.brand || 'Element'}), + detail: e.message || "", + }); + } + // Could not load local config, this is expected in most cases. } diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index b5a97fc..769f23c 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -1,4 +1,6 @@ { + "Your %(brand)s is misconfigured": "Your %(brand)s is misconfigured", + "Your custom %(brand)s configuration contains invalid JSON. Please correct the problem and reopen %(brand)s.": "Your custom %(brand)s configuration contains invalid JSON. Please correct the problem and reopen %(brand)s.", "Cancel": "Cancel", "Close Element": "Close Element", "Are you sure you want to quit?": "Are you sure you want to quit?",