Skip to content

Commit

Permalink
Add a quick&dirty way to get callback errors
Browse files Browse the repository at this point in the history
  • Loading branch information
daid committed Aug 8, 2024
1 parent d24b390 commit b476501
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/scriptInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>)
return;
Expand Down Expand Up @@ -232,6 +233,8 @@ class ScriptSimpleCallback

//Return the script object linked to this callback, if any.
P<ScriptObject> getScriptObject();

static inline string last_error;
};
template<> void convert<ScriptSimpleCallback>::param(lua_State* L, int& idx, ScriptSimpleCallback& callback);

Expand Down

0 comments on commit b476501

Please sign in to comment.