From 53c3cbfe268e0dcab10b343e1b0bac46e676f097 Mon Sep 17 00:00:00 2001 From: tobspr Date: Sat, 15 Jan 2022 12:30:57 +0100 Subject: [PATCH 1/2] Show errors when loading mods --- src/js/mods/modloader.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/js/mods/modloader.js b/src/js/mods/modloader.js index f5145207..d7e10391 100644 --- a/src/js/mods/modloader.js +++ b/src/js/mods/modloader.js @@ -94,19 +94,29 @@ export class ModLoader { } mods.forEach(modCode => { - const func = new Function(modCode); - func(); + try { + const func = new Function(modCode); + const response = func(); + } catch (ex) { + console.error(ex); + alert("Failed to parse mod (launch with --dev for more info): " + ex); + } }); } catch (ex) { - alert("Failed to load mods: " + ex); + alert("Failed to load mods (launch with --dev for more info): " + ex); } } this.initialized = true; this.modLoadQueue.forEach(modClass => { - const mod = new (modClass())(this.app, this); - mod.init(); - this.mods.push(mod); + try { + const mod = new (modClass())(this.app, this); + mod.init(); + this.mods.push(mod); + } catch (ex) { + console.error(ex); + alert("Failed to initialize mods (launch with --dev for more info): " + ex); + } }); this.modLoadQueue = []; this.signals.postInit.dispatch(); From 4e33eb5a7c5d83b26078c14c0c5a389cba5277bf Mon Sep 17 00:00:00 2001 From: tobspr Date: Sat, 15 Jan 2022 12:37:22 +0100 Subject: [PATCH 2/2] Update confirm dialgo --- electron/index.js | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/electron/index.js b/electron/index.js index 1b8b4b5e..3c567893 100644 --- a/electron/index.js +++ b/electron/index.js @@ -351,21 +351,10 @@ ipcMain.handle("get-mods", async () => { buttons: ["Exit Game", "Continue"], type: "warning", defaultId: 0, - - checkboxLabel: - "I understand that mods have access to my file system and can be potentially harmful", - checkboxChecked: false, cancelId: 0, }); if (response.response === 1) { - if (response.checkboxChecked) { - break; - } else { - await dialog.showMessageBox(win, { - message: - "Please confirm that you have understood the risks by checking the checkbox in the next dialog.", - }); - } + break; } if (response.response === 0) { process.exit(0);