aboutsummaryrefslogtreecommitdiff
path: root/src/script/cpp_api/s_base.cpp
diff options
context:
space:
mode:
authorJude Melton-Houghton <jwmhjwmh@gmail.com>2022-12-15 07:37:49 -0500
committerGitHub <noreply@github.com>2022-12-15 07:37:49 -0500
commit0fc97a1483961e0bc617ca67a348dcb2cbeb6bc0 (patch)
treef18593c33d9da74cc49525ab7badab5f55836ef8 /src/script/cpp_api/s_base.cpp
parent1f3b5e553bb581deddf468d62954ff238ebb1ac8 (diff)
downloadminetest-0fc97a1483961e0bc617ca67a348dcb2cbeb6bc0.tar.xz
Use a Lua error handler that calls tostring (#11913)
Diffstat (limited to 'src/script/cpp_api/s_base.cpp')
-rw-r--r--src/script/cpp_api/s_base.cpp7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/script/cpp_api/s_base.cpp b/src/script/cpp_api/s_base.cpp
index e8d973de1..b91f59613 100644
--- a/src/script/cpp_api/s_base.cpp
+++ b/src/script/cpp_api/s_base.cpp
@@ -103,11 +103,8 @@ ScriptApiBase::ScriptApiBase(ScriptingType type):
#endif
lua_rawseti(m_luastack, LUA_REGISTRYINDEX, CUSTOM_RIDX_SCRIPTAPI);
- // Add and save an error handler
- lua_getglobal(m_luastack, "debug");
- lua_getfield(m_luastack, -1, "traceback");
- lua_rawseti(m_luastack, LUA_REGISTRYINDEX, CUSTOM_RIDX_BACKTRACE);
- lua_pop(m_luastack, 1); // pop debug
+ lua_pushcfunction(m_luastack, script_error_handler);
+ lua_rawseti(m_luastack, LUA_REGISTRYINDEX, CUSTOM_RIDX_ERROR_HANDLER);
// Add a C++ wrapper function to catch exceptions thrown in Lua -> C++ calls
#if USE_LUAJIT