diff --git a/src/js/application.js b/src/js/application.js index 98f3718c..088020e9 100644 --- a/src/js/application.js +++ b/src/js/application.js @@ -52,7 +52,7 @@ export class Application { try { await MODS.initMods(); } catch (ex) { - alert("Failed to load mods (launch with --dev for more info): \n\n" + ex); + throw new Error("Failed to initialize mods", { cause: ex }); } this.unloaded = false; diff --git a/src/js/core/animation_frame.js b/src/js/core/animation_frame.js index 1e0de209..1724d79b 100644 --- a/src/js/core/animation_frame.js +++ b/src/js/core/animation_frame.js @@ -52,11 +52,7 @@ export class AnimationFrame { dt = resetDtMs; } - try { - this.frameEmitted.dispatch(dt); - } catch (ex) { - console.error(ex); - } + this.frameEmitted.dispatch(dt); this.lastTime = time; window.requestAnimationFrame(this.boundMethod); } diff --git a/src/js/core/state_manager.js b/src/js/core/state_manager.js index 733fce5e..52815d27 100644 --- a/src/js/core/state_manager.js +++ b/src/js/core/state_manager.js @@ -95,12 +95,8 @@ export class StateManager { const dialogParent = document.createElement("div"); dialogParent.classList.add("modalDialogParent"); document.body.appendChild(dialogParent); - try { - this.currentState.internalEnterCallback(payload); - } catch (ex) { - console.error(ex); - throw ex; - } + + this.currentState.internalEnterCallback(payload); this.app.sound.playThemeMusic(this.currentState.getThemeMusic()); diff --git a/src/js/game/modes/regular.js b/src/js/game/modes/regular.js index aafa9fc7..c9e2edc3 100644 --- a/src/js/game/modes/regular.js +++ b/src/js/game/modes/regular.js @@ -275,7 +275,7 @@ function generateUpgrades() { try { ShapeDefinition.fromShortKey(shape); } catch (ex) { - throw new Error("Invalid upgrade goal: '" + ex + "' for shape" + shape); + throw new Error("Invalid upgrade goal for shape " + shape, { cause: ex }); } }); }); @@ -305,7 +305,7 @@ export function generateLevelDefinitions() { try { ShapeDefinition.fromShortKey(shape); } catch (ex) { - throw new Error("Invalid tutorial goal: '" + ex + "' for shape" + shape); + throw new Error("Invalid tutorial goal for shape " + shape, { cause: ex }); } }); } diff --git a/src/js/mods/modloader.ts b/src/js/mods/modloader.ts index e9c93381..f071ed27 100644 --- a/src/js/mods/modloader.ts +++ b/src/js/mods/modloader.ts @@ -2,7 +2,6 @@ import { GLOBAL_APP } from "@/core/globals"; import { SavegameStoredMods } from "@/savegame/savegame_typedefs"; import { createLogger } from "../core/logging"; import { DisabledMod } from "./disabled_mod"; -import { ErroredMod } from "./errored_mod"; import { Mod, ModConstructor } from "./mod"; import { ModInfo, ModMetadata, ModQueueEntry } from "./mod_metadata"; import { MOD_SIGNALS } from "./mod_signals"; @@ -84,22 +83,16 @@ export class ModLoader { queue.map(async e => ({ entry: e, mod: await this.loadMod(e) })) ); - // Initialize all mods sequentially and collect errors + // Initialize all mods sequentially // TODO: Also collect early errors from the main process for (const { entry, mod } of loadedMods) { - try { - await mod.init(); - } catch (err) { - if (err instanceof Error) { - mod.errors.push(err); - } - } - this.mods.set(mod.id, { source: entry.source, file: entry.file, mod, }); + + await mod.init(); } } @@ -139,13 +132,7 @@ export class ModLoader { return new DisabledMod(entry.metadata, this.app, this); } - try { - return await this.createModInstance(entry.metadata); - } catch (err) { - const mod = new ErroredMod(entry.metadata, this.app, this); - mod.errors.push(err instanceof Error ? err : new Error(err.toString())); - return mod; - } + return await this.createModInstance(entry.metadata); } private async createModInstance(metadata: ModMetadata): Promise {