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:
parent
4ef93fe25f
commit
033128d8dc
4 changed files with 18 additions and 11 deletions
|
@ -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.
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue