1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-12-13 18:21: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 => {
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();