From 2cbe726f08d9a9a26f36f3e236569de3e782d0ef Mon Sep 17 00:00:00 2001 From: Chris Blyth Date: Sun, 6 Oct 2024 08:08:01 +0100 Subject: [PATCH] Try/Catch on message receiver --- src/366x366/app/index.js | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/366x366/app/index.js b/src/366x366/app/index.js index 9480e8e..76c8bdf 100644 --- a/src/366x366/app/index.js +++ b/src/366x366/app/index.js @@ -40,20 +40,28 @@ if (settings.hasSettings()) { } msgq.addEventListener("message", (messageKey, message) => { - var key = messageKey.split(":")[0]; - if (key === "weather") { - weather.processWeatherData(message); - } else if (key === "settingChange") { - settings.settingUpdate(message); - } else if (key === "settingsChunk") { - for (let index = 0; index < message.length; index++) { - const element = message[index]; - settings.settingUpdate(element); + try + { + var key = messageKey.split(":")[0]; + if (key === "weather") { + weather.processWeatherData(message); + } else if (key === "settingChange") { + settings.settingUpdate(message); + } else if (key === "settingsChunk") { + for (let index = 0; index < message.length; index++) { + const element = message[index]; + settings.settingUpdate(element); + } + } else if (key === "settingsComplete") { + startingEl.style.display = "none"; + settings.saveSettings(); + } else { + console.error(`Unknown key: ${key}`); } - } else if (key === "settingsComplete") { - startingEl.style.display = "none"; - settings.saveSettings(); } + catch (e) { + console.error(e); + } }); let prereleaseEl = document.getElementById("pr");