18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-19 02:56:01 +01:00

fix(simulation): on Linux an exception ends a test run with its verdict too

The runtime_error the simulator throws on a fatal problem was caught on Windows
only. On Linux a test run aborted on it, with the code of abort() and no
`test:` line. It is caught there too in test mode and ends the test with the
error code and the reason; outside a test it is thrown on as before.
This commit is contained in:
jerrrrycho
2026-11-08 11:40:13 +01:00
parent e5aafd154f
commit 349ffb1caf

View File

@@ -164,20 +164,25 @@ int main(int argc, char *argv[])
{
ErrorLog("Critical error, memory allocation failure: " + std::string(Error.what()));
}
#ifdef _WIN32
catch (std::runtime_error const &Error)
{
#ifndef _WIN32
// outside a test the error ends the program as it always did there, uncaught
if (false == Global.test.enabled)
throw;
#endif
ErrorLog(std::format("Critical error: {}", Error.what()));
// in test mode nobody is there to close the box, the exit code tells of the error
simulation::test().conclude(simulation::test_result::error, std::format("critical error: {}", Error.what()));
#ifdef _WIN32
if (false == Global.test.enabled)
{
std::string msg = "Simulator crash occured :(\n";
msg += Error.what();
MessageBoxA(nullptr, msg.c_str(), "Simulator crashed :(", MB_ICONERROR);
}
}
#endif
}
}
#ifndef _WIN32
fflush(stdout);