mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-19 20:24:59 +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:
9
EU07.cpp
9
EU07.cpp
@@ -164,20 +164,25 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
ErrorLog("Critical error, memory allocation failure: " + std::string(Error.what()));
|
ErrorLog("Critical error, memory allocation failure: " + std::string(Error.what()));
|
||||||
}
|
}
|
||||||
#ifdef _WIN32
|
|
||||||
catch (std::runtime_error const &Error)
|
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()));
|
ErrorLog(std::format("Critical error: {}", Error.what()));
|
||||||
// in test mode nobody is there to close the box, the exit code tells of the error
|
// 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()));
|
simulation::test().conclude(simulation::test_result::error, std::format("critical error: {}", Error.what()));
|
||||||
|
#ifdef _WIN32
|
||||||
if (false == Global.test.enabled)
|
if (false == Global.test.enabled)
|
||||||
{
|
{
|
||||||
std::string msg = "Simulator crash occured :(\n";
|
std::string msg = "Simulator crash occured :(\n";
|
||||||
msg += Error.what();
|
msg += Error.what();
|
||||||
MessageBoxA(nullptr, msg.c_str(), "Simulator crashed :(", MB_ICONERROR);
|
MessageBoxA(nullptr, msg.c_str(), "Simulator crashed :(", MB_ICONERROR);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|||||||
Reference in New Issue
Block a user