diff --git a/src/posix/cocoa/i_main_except.cpp b/src/posix/cocoa/i_main_except.cpp index a61eca2ccb..afb0ba7e41 100644 --- a/src/posix/cocoa/i_main_except.cpp +++ b/src/posix/cocoa/i_main_except.cpp @@ -32,9 +32,11 @@ */ // Workaround for GCC Objective-C++ with C++ exceptions bug. -#include "doomerrors.h" #include +#include "doomerrors.h" +#include "vm.h" + // Import some functions from i_main.mm void call_terms(); void Mac_I_FatalError(const char* const message); @@ -50,10 +52,21 @@ void OriginalMainExcept(int argc, char** argv) { const char* const message = error.what(); - if (NULL != message) + if (strcmp(message, "NoRunExit")) { - if (strcmp(message, "NoRunExit")) fprintf(stderr, "%s\n", message); - Mac_I_FatalError(message); + if (CVMAbortException::stacktrace.IsNotEmpty()) + { + Printf("%s", CVMAbortException::stacktrace.GetChars()); + } + + if (batchrun) + { + Printf("%s\n", message); + } + else + { + Mac_I_FatalError(message); + } } exit(-1); diff --git a/src/posix/sdl/i_main.cpp b/src/posix/sdl/i_main.cpp index 0c23892948..3d7912fc8b 100644 --- a/src/posix/sdl/i_main.cpp +++ b/src/posix/sdl/i_main.cpp @@ -52,6 +52,7 @@ #include "cmdlib.h" #include "r_utility.h" #include "doomstat.h" +#include "vm.h" // MACROS ------------------------------------------------------------------ @@ -261,16 +262,31 @@ int main (int argc, char **argv) catch (std::exception &error) { I_ShutdownJoysticks(); - if (error.what () && strcmp(error.what(), "NoRunExit")) - fprintf (stderr, "%s\n", error.what ()); + const char *const message = error.what(); + + if (strcmp(message, "NoRunExit")) + { + if (CVMAbortException::stacktrace.IsNotEmpty()) + { + Printf("%s", CVMAbortException::stacktrace.GetChars()); + } + + if (batchrun) + { + Printf("%s\n", message); + } + else + { #ifdef __APPLE__ - Mac_I_FatalError(error.what()); + Mac_I_FatalError(message); #endif // __APPLE__ #ifdef __linux__ - Linux_I_FatalError(error.what()); + Linux_I_FatalError(message); #endif // __linux__ + } + } exit (-1); } diff --git a/src/win32/i_main.cpp b/src/win32/i_main.cpp index 6a75a597a9..4bd3aed66e 100644 --- a/src/win32/i_main.cpp +++ b/src/win32/i_main.cpp @@ -71,6 +71,7 @@ #include "r_utility.h" #include "g_levellocals.h" #include "s_sound.h" +#include "vm.h" #include "stats.h" #include "st_start.h" @@ -1057,6 +1058,11 @@ void DoMain (HINSTANCE hInstance) auto msg = error.what(); if (strcmp(msg, "NoRunExit")) { + if (CVMAbortException::stacktrace.IsNotEmpty()) + { + Printf("%s", CVMAbortException::stacktrace.GetChars()); + } + if (!batchrun) { ShowErrorPane(msg);