* @brief Calls lua_pcall under a C++ try/catch -- escaped exceptions become LUA_ERRRUN. */
| 59 | * @brief Calls lua_pcall under a C++ try/catch -- escaped exceptions become LUA_ERRRUN. |
| 60 | */ |
| 61 | [[nodiscard]] static int guardedPcall(lua_State* L, int nargs, int nresults, int msgh) noexcept |
| 62 | { |
| 63 | try { |
| 64 | return lua_pcall(L, nargs, nresults, msgh); |
| 65 | } catch (...) { |
| 66 | qWarning() << "[LuaScriptEngine] Uncaught C++ exception escaped lua_pcall -- " |
| 67 | "treating as LUA_ERRRUN. Check Lua build unwind tables."; |
| 68 | try { |
| 69 | lua_settop(L, 0); |
| 70 | lua_pushstring(L, "uncaught Lua exception (escaped lua_pcall)"); |
| 71 | } catch (...) { |
| 72 | } |
| 73 | return LUA_ERRRUN; |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * @brief Lua atpanic handler that throws so abort() is never reached. |
no test coverage detected