mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-24 00:23:12 +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
+5
@@ -670,6 +670,7 @@ async function loadPlugins(pluginInfos) {
|
|||||||
|
|
||||||
let pluginLoadStarted = Date.now();
|
let pluginLoadStarted = Date.now();
|
||||||
let MasterPlugin = plugin.BaseMasterPlugin;
|
let MasterPlugin = plugin.BaseMasterPlugin;
|
||||||
|
try {
|
||||||
if (pluginInfo.masterEntrypoint) {
|
if (pluginInfo.masterEntrypoint) {
|
||||||
({ MasterPlugin } = require(`./plugins/${pluginInfo.name}/${pluginInfo.masterEntrypoint}`));
|
({ MasterPlugin } = require(`./plugins/${pluginInfo.name}/${pluginInfo.masterEntrypoint}`));
|
||||||
}
|
}
|
||||||
@@ -678,6 +679,10 @@ async function loadPlugins(pluginInfos) {
|
|||||||
await masterPlugin.init();
|
await masterPlugin.init();
|
||||||
plugins.set(pluginInfo.name, masterPlugin);
|
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`);
|
console.log(`Clusterio | Loaded plugin ${pluginInfo.name} in ${Date.now() - pluginLoadStarted}ms`);
|
||||||
/*
|
/*
|
||||||
main:new masterPlugin({
|
main:new masterPlugin({
|
||||||
|
|||||||
Reference in new issue
Block a user