1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Show better description to users when std::bad_alloc happens

This commit is contained in:
sfan5 2023-09-05 19:43:33 +02:00
parent 4ef93fe25f
commit 033128d8dc
4 changed files with 18 additions and 11 deletions

View file

@ -32,6 +32,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#ifdef _MSC_VER
#include <dbghelp.h>
#include <windows.h>
#include <eh.h>
#include "version.h"
#include "filesys.h"
#endif
@ -74,6 +76,13 @@ void fatal_error_fn(const char *msg, const char *file,
abort();
}
std::string debug_describe_exc(const std::exception &e)
{
if (dynamic_cast<const std::bad_alloc*>(&e))
return "C++ out of memory";
return std::string("\"").append(e.what()).append("\"");
}
#ifdef _MSC_VER
const char *Win32ExceptionCodeToString(DWORD exception_code)