mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-12 23:04:52 +09:00
Handle errors during master plugin initialization
Catch errors thrown when constructing or initializing master pluigns and wrap them in PluginError to ensure that they are properly reported as plugin errors.
This commit is contained in:
1 parent
ddd2027739
commit
cb1d744060
1 file changed
+11
-6
@@ -670,13 +670,18 @@ async function loadPlugins(pluginInfos) {
|
||||
|
||||
let pluginLoadStarted = Date.now();
|
||||
let MasterPlugin = plugin.BaseMasterPlugin;
|
||||
if (pluginInfo.masterEntrypoint) {
|
||||
({ MasterPlugin } = require(`./plugins/${pluginInfo.name}/${pluginInfo.masterEntrypoint}`));
|
||||
}
|
||||
try {
|
||||
if (pluginInfo.masterEntrypoint) {
|
||||
({ MasterPlugin } = require(`./plugins/${pluginInfo.name}/${pluginInfo.masterEntrypoint}`));
|
||||
}
|
||||
|
||||
let masterPlugin = new MasterPlugin(pluginInfo);
|
||||
await masterPlugin.init();
|
||||
plugins.set(pluginInfo.name, masterPlugin);
|
||||
let masterPlugin = new MasterPlugin(pluginInfo);
|
||||
await masterPlugin.init();
|
||||
plugins.set(pluginInfo.name, masterPlugin);
|
||||
|
||||
} catch (err) {
|
||||
throw new errors.PluginError(pluginInfo.name, err)
|
||||
}
|
||||
|
||||
console.log(`Clusterio | Loaded plugin ${pluginInfo.name} in ${Date.now() - pluginLoadStarted}ms`);
|
||||
/*
|
||||
|
||||
Reference in new issue
Block a user