From 349ffb1caf0ec40a8c350a29e36ca7cce383e38a Mon Sep 17 00:00:00 2001 From: jerrrrycho Date: Sun, 8 Nov 2026 11:40:13 +0100 Subject: [PATCH] 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. --- EU07.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/EU07.cpp b/EU07.cpp index 0fbabba5b..4bc453867 100644 --- a/EU07.cpp +++ b/EU07.cpp @@ -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);