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:
@@ -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.
|
||||
}
|
||||
|
Reference in New Issue
Block a user