Throw error when simulation script can't be loaded

When a script in "simulation/helpers/" contained an error. Files in
"simulation/components" aren't loaded. The return value of
`LoadDefaultScripts` indicated an error but was ignored. The simulation
still tried to start.

Now instead of returning a ignoreable error code the error is thrown. In
the common path the error is implicitly rethrown to the JS-function
which tried to start the game.

fixes: #8133
This commit is contained in:
phosit
2025-11-05 19:38:19 +01:00
parent 977bf5c0d1
commit 9a526bcae1
5 changed files with 44 additions and 29 deletions
+12 -5
View File
@@ -594,11 +594,18 @@ bool Init(const CmdLineArgs& args, int flags)
// on anything else.)
if (args.Has("dumpSchema"))
{
CSimulation2 sim{NULL, *g_ScriptContext, NULL};
sim.LoadDefaultScripts();
std::ofstream f("entity.rng", std::ios_base::out | std::ios_base::trunc);
f << sim.GenerateSchema();
debug_printf("Generated entity.rng\n");
try
{
CSimulation2 sim{NULL, *g_ScriptContext, NULL};
sim.LoadDefaultScripts();
std::ofstream f("entity.rng", std::ios_base::out | std::ios_base::trunc);
f << sim.GenerateSchema();
debug_printf("Generated entity.rng\n");
}
catch (const CSimulation2::LoadScriptError& e)
{
LOGERROR("%s", e.what());
}
return false;
}