mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-13 16:45:20 +02:00
Show better description to users when std::bad_alloc happens
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user