diff options
author | Jude Melton-Houghton <jwmhjwmh@gmail.com> | 2022-12-15 07:37:49 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-15 07:37:49 -0500 |
commit | 0fc97a1483961e0bc617ca67a348dcb2cbeb6bc0 (patch) | |
tree | f18593c33d9da74cc49525ab7badab5f55836ef8 /src/script/common/c_internal.h | |
parent | 1f3b5e553bb581deddf468d62954ff238ebb1ac8 (diff) | |
download | minetest-0fc97a1483961e0bc617ca67a348dcb2cbeb6bc0.tar.xz |
Use a Lua error handler that calls tostring (#11913)
Diffstat (limited to 'src/script/common/c_internal.h')
-rw-r--r-- | src/script/common/c_internal.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/script/common/c_internal.h b/src/script/common/c_internal.h index 5cbcbb7db..c8bce099c 100644 --- a/src/script/common/c_internal.h +++ b/src/script/common/c_internal.h @@ -54,7 +54,7 @@ enum { CUSTOM_RIDX_SCRIPTAPI, CUSTOM_RIDX_GLOBALS_BACKUP, CUSTOM_RIDX_CURRENT_MOD_NAME, - CUSTOM_RIDX_BACKTRACE, + CUSTOM_RIDX_ERROR_HANDLER, CUSTOM_RIDX_HTTP_API_LUA, CUSTOM_RIDX_METATABLE_MAP, @@ -78,7 +78,7 @@ enum { // Pushes the error handler onto the stack and returns its index #define PUSH_ERROR_HANDLER(L) \ - (lua_rawgeti((L), LUA_REGISTRYINDEX, CUSTOM_RIDX_BACKTRACE), lua_gettop((L))) + (lua_rawgeti((L), LUA_REGISTRYINDEX, CUSTOM_RIDX_ERROR_HANDLER), lua_gettop((L))) #define PCALL_RESL(L, RES) { \ int result_ = (RES); \ @@ -121,6 +121,8 @@ enum RunCallbacksMode std::string script_get_backtrace(lua_State *L); // Wrapper for CFunction calls that converts C++ exceptions to Lua errors int script_exception_wrapper(lua_State *L, lua_CFunction f); +// Acts as the error handler for lua_pcall +int script_error_handler(lua_State *L); // Takes an error from lua_pcall and throws it as a LuaError void script_error(lua_State *L, int pcall_result, const char *mod, const char *fxn); |