From bc7d3abeade838a781813924882e98e7d8ebc759 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Mon, 27 Apr 2026 02:16:46 +0300 Subject: [PATCH] add lua panic handler --- src/logic/scripting/lua/lua_engine.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/logic/scripting/lua/lua_engine.cpp b/src/logic/scripting/lua/lua_engine.cpp index 0143f6a9e..bd2f0359b 100644 --- a/src/logic/scripting/lua/lua_engine.cpp +++ b/src/logic/scripting/lua/lua_engine.cpp @@ -99,7 +99,15 @@ static void create_libs(State* L, StateType stateType) { addfunc(L, "crc32", lua::wrap); } +static int l_panic_handler(lua::State* L) { + logger.error() << "PANIC: unprotected error in call to Lua API: " << lua::tostring(L, -1); + logger.flush(); + abort(); +} + void lua::init_state(State* L, StateType stateType) { + lua_atpanic(L, l_panic_handler); + // Allowed standard libraries luaL_openlibs(L);