From b4765014f0fb41307b7bc7575767dc6bb17fbe2a Mon Sep 17 00:00:00 2001 From: Daid Date: Thu, 8 Aug 2024 09:44:40 +0200 Subject: [PATCH] Add a quick&dirty way to get callback errors --- src/scriptInterface.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/scriptInterface.h b/src/scriptInterface.h index 732097ab..7026b07b 100644 --- a/src/scriptInterface.h +++ b/src/scriptInterface.h @@ -160,6 +160,7 @@ class ScriptSimpleCallback if (lua_pcall(L, i, 1, 0)) { LOG(ERROR) << "Callback function error: " << lua_tostring(L, -1); + last_error = lua_tostring(L, -1); lua_pop(L, 2); if constexpr (std::is_void_v) return; @@ -232,6 +233,8 @@ class ScriptSimpleCallback //Return the script object linked to this callback, if any. P getScriptObject(); + + static inline string last_error; }; template<> void convert::param(lua_State* L, int& idx, ScriptSimpleCallback& callback);