Is it possible to know if LuaBridge called my code
rpatters1 opened this issue · 1 comments
rpatters1 commented
I am trying to get robust error handling in place with code that may be in a callback from LuaBridge or may not. Is there any way to tell if LuaBridge called my code? That is, if LuaBridge is somewhere higher on the stack? Conceptually I would like to do this:
void error_handler(luabridge::LuaException &e)
{
if (<called-by-LuaBridge>)
throw e; // let LuaBridge and Lua error-handling handle it
display_message_to_user(e.what());
lua_close(e.state());
}
rpatters1 commented
It looks like this works:
void error_handler(luabridge::LuaException &e)
{
lua_Debug ar;
if (lua_getstack(e.state(), 0, &ar))
throw e; // let LuaBridge and Lua error-handling handle it
display_message_to_user(e.what());
lua_close(e.state());
}
If you agree, please feel free to close this issue. If there are improvements to suggest, I am interested in hearing them.