aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api
diff options
context:
space:
mode:
authorKahrl <kahrl@gmx.net>2015-08-25 07:44:53 +0200
committerest31 <MTest31@outlook.com>2015-08-27 01:56:06 +0200
commit3304e1e517fb8aac008c4684e72a4b59b408414a (patch)
treeddcc820601c02d6783578b7accc68d35a2d312fc /src/script/lua_api
parent8658c8d9b5f30dc952eed29a19d619de9210474c (diff)
downloadminetest-3304e1e517fb8aac008c4684e72a4b59b408414a.tar.gz
minetest-3304e1e517fb8aac008c4684e72a4b59b408414a.tar.bz2
minetest-3304e1e517fb8aac008c4684e72a4b59b408414a.zip
Push error handler afresh each time lua_pcall is used
Fixes "double fault" / "error in error handling" messages (issue #1423) and instead shows a complete backtrace.
Diffstat (limited to 'src/script/lua_api')
-rw-r--r--src/script/lua_api/l_env.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/script/lua_api/l_env.cpp b/src/script/lua_api/l_env.cpp
index 28afdd071..4e0164d90 100644
--- a/src/script/lua_api/l_env.cpp
+++ b/src/script/lua_api/l_env.cpp
@@ -52,8 +52,7 @@ void LuaABM::trigger(ServerEnvironment *env, v3s16 p, MapNode n,
sanity_check(lua_checkstack(L, 20));
StackUnroller stack_unroller(L);
- lua_pushcfunction(L, script_error_handler);
- int errorhandler = lua_gettop(L);
+ int error_handler = PUSH_ERROR_HANDLER(L);
// Get registered_abms
lua_getglobal(L, "core");
@@ -80,7 +79,7 @@ void LuaABM::trigger(ServerEnvironment *env, v3s16 p, MapNode n,
lua_pushnumber(L, active_object_count);
lua_pushnumber(L, active_object_count_wider);
- int result = lua_pcall(L, 4, 0, errorhandler);
+ int result = lua_pcall(L, 4, 0, error_handler);
if (result)
scriptIface->scriptError(result, "LuaABM::trigger");
@@ -412,8 +411,7 @@ int ModApiEnvMod::l_add_item(lua_State *L)
if(item.empty() || !item.isKnown(getServer(L)->idef()))
return 0;
- lua_pushcfunction(L, script_error_handler);
- int errorhandler = lua_gettop(L);
+ int error_handler = PUSH_ERROR_HANDLER(L);
// Use spawn_item to spawn a __builtin:item
lua_getglobal(L, "core");
@@ -424,9 +422,9 @@ int ModApiEnvMod::l_add_item(lua_State *L)
lua_pushvalue(L, 1);
lua_pushstring(L, item.getItemString().c_str());
- PCALL_RESL(L, lua_pcall(L, 2, 1, errorhandler));
+ PCALL_RESL(L, lua_pcall(L, 2, 1, error_handler));
- lua_remove(L, errorhandler); // Remove error handler
+ lua_remove(L, error_handler);
return 1;
}