Annotate error when loading module.json fails

If a plugin has an invalid module/module.json file this should also give
a readable error.
This commit is contained in:
Hornwitser committed 2023-02-15 20:31:02 +01:00
1 parent 033de0e20a
commit 58e5d96e1d
1 file changed
+6 -1
+6 -1
View File
@@ -757,7 +757,12 @@ rcon.print(game.table_to_json(players))`.replace(/\r?\n/g, " ");
throw new Error(`Module for plugin ${pluginName} is missing module.json`);
}
let module = JSON.parse(await fs.readFile(moduleJsonPath));
let module;
try {
module = JSON.parse(await fs.readFile(moduleJsonPath));
} catch (err) {
throw new Error(`Loading module/module.json in plugin ${pluginName} failed: ${err.message}`);
}
if (module.name !== pluginName) {
throw new Error(`Expected name of module for plugin ${pluginName} to match the plugin name`);
}