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

@ -42,7 +42,8 @@ int script_exception_wrapper(lua_State *L, lua_CFunction f)
} catch (const char *s) { // Catch and convert exceptions.
lua_pushstring(L, s);
} catch (std::exception &e) {
lua_pushstring(L, e.what());
std::string e_descr = debug_describe_exc(e);
lua_pushlstring(L, e_descr.c_str(), e_descr.size());
}
return lua_error(L); // Rethrow as a Lua error.
}