1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-12-14 02:31:51 +00:00

Show errors when loading mods

This commit is contained in:
tobspr 2022-01-15 12:30:57 +01:00
parent eba9163a33
commit 53c3cbfe26

View File

@ -94,19 +94,29 @@ export class ModLoader {
} }
mods.forEach(modCode => { mods.forEach(modCode => {
try {
const func = new Function(modCode); const func = new Function(modCode);
func(); const response = func();
} catch (ex) {
console.error(ex);
alert("Failed to parse mod (launch with --dev for more info): " + ex);
}
}); });
} catch (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.initialized = true;
this.modLoadQueue.forEach(modClass => { this.modLoadQueue.forEach(modClass => {
try {
const mod = new (modClass())(this.app, this); const mod = new (modClass())(this.app, this);
mod.init(); mod.init();
this.mods.push(mod); this.mods.push(mod);
} catch (ex) {
console.error(ex);
alert("Failed to initialize mods (launch with --dev for more info): " + ex);
}
}); });
this.modLoadQueue = []; this.modLoadQueue = [];
this.signals.postInit.dispatch(); this.signals.postInit.dispatch();