Revert "Fix reporting unhandled exceptions in MSVC"
This reverts commit 4d3a0b6602
.
Conflicts:
src/app/main.cpp
master
parent
65d26733fa
commit
551710646b
|
@ -135,45 +135,34 @@ int SDL_MAIN_FUNC(int argc, char *argv[])
|
|||
InitializeEventTypeTexts();
|
||||
|
||||
int code = 0;
|
||||
try
|
||||
CApplication app(systemUtils.get()); // single instance of the application
|
||||
|
||||
ParseArgsStatus status = app.ParseArguments(argc, argv);
|
||||
if (status == PARSE_ARGS_FAIL)
|
||||
{
|
||||
CApplication app(systemUtils.get()); // single instance of the application
|
||||
|
||||
ParseArgsStatus status = app.ParseArguments(argc, argv);
|
||||
if (status == PARSE_ARGS_FAIL)
|
||||
{
|
||||
systemUtils->SystemDialog(SDT_ERROR, "COLOBOT - Fatal Error", "Invalid commandline arguments!\n");
|
||||
return app.GetExitCode();
|
||||
}
|
||||
else if (status == PARSE_ARGS_HELP)
|
||||
{
|
||||
return app.GetExitCode();
|
||||
}
|
||||
|
||||
|
||||
if (!app.Create())
|
||||
{
|
||||
code = app.GetExitCode();
|
||||
if (code != 0 && !app.GetErrorMessage().empty())
|
||||
{
|
||||
systemUtils->SystemDialog(SDT_ERROR, "COLOBOT - Fatal Error", app.GetErrorMessage());
|
||||
}
|
||||
logger.Info("Didn't run main loop. Exiting with code %d\n", code);
|
||||
return code;
|
||||
}
|
||||
|
||||
code = app.Run();
|
||||
systemUtils->SystemDialog(SDT_ERROR, "COLOBOT - Fatal Error", "Invalid commandline arguments!\n");
|
||||
return app.GetExitCode();
|
||||
}
|
||||
catch (std::exception& e)
|
||||
else if (status == PARSE_ARGS_HELP)
|
||||
{
|
||||
CSignalHandlers::HandleUncaughtException(e);
|
||||
return app.GetExitCode();
|
||||
}
|
||||
catch (...)
|
||||
|
||||
if (! app.Create())
|
||||
{
|
||||
CSignalHandlers::HandleOtherUncaughtException();
|
||||
code = app.GetExitCode();
|
||||
if (code != 0 && !app.GetErrorMessage().empty())
|
||||
{
|
||||
systemUtils->SystemDialog(SDT_ERROR, "COLOBOT - Fatal Error", app.GetErrorMessage());
|
||||
}
|
||||
logger.Info("Didn't run main loop. Exiting with code %d\n", code);
|
||||
return code;
|
||||
}
|
||||
|
||||
code = app.Run();
|
||||
|
||||
logger.Info("Exiting with code %d\n", code);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ void CSignalHandlers::Init(CSystemUtils* systemUtils)
|
|||
signal(SIGABRT, SignalHandler);
|
||||
signal(SIGFPE, SignalHandler);
|
||||
signal(SIGILL, SignalHandler);
|
||||
std::set_terminate(UnhandledExceptionHandler);
|
||||
}
|
||||
|
||||
void CSignalHandlers::SignalHandler(int sig)
|
||||
|
@ -74,23 +75,29 @@ std::string demangle(const char* name) {
|
|||
#else
|
||||
// For MSVC and others
|
||||
// In MSVC typeinfo(e).name() should be already demangled
|
||||
std::string demangle(const char* name)
|
||||
{
|
||||
std::string demangle(const char* name) {
|
||||
return name;
|
||||
}
|
||||
#endif
|
||||
|
||||
void CSignalHandlers::HandleUncaughtException(const std::exception& e)
|
||||
void CSignalHandlers::UnhandledExceptionHandler()
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "Type: " << demangle(typeid(e).name()) << std::endl;
|
||||
ss << "Message: " << e.what();
|
||||
ReportError(ss.str());
|
||||
}
|
||||
|
||||
void CSignalHandlers::HandleOtherUncaughtException()
|
||||
{
|
||||
ReportError("Unknown unhandled exception (not inherited from std::exception)");
|
||||
std::exception_ptr exptr = std::current_exception();
|
||||
try
|
||||
{
|
||||
std::rethrow_exception(exptr);
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "Type: " << demangle(typeid(e).name()) << std::endl;
|
||||
ss << "Message: " << e.what();
|
||||
ReportError(ss.str());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
ReportError("Unknown unhandled exception (not inherited from std::exception)");
|
||||
}
|
||||
}
|
||||
|
||||
void CSignalHandlers::ReportError(const std::string& errorMessage)
|
||||
|
|
|
@ -28,9 +28,6 @@ class CSignalHandlers
|
|||
public:
|
||||
static void Init(CSystemUtils* systemUtils);
|
||||
|
||||
static void HandleUncaughtException(const std::exception& e);
|
||||
static void HandleOtherUncaughtException();
|
||||
|
||||
private:
|
||||
static void SignalHandler(int sig);
|
||||
static void UnhandledExceptionHandler();
|
||||
|
|
Loading…
Reference in New Issue