Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to know if LuaBridge called my code #295

Open
rpatters1 opened this issue Sep 5, 2022 · 1 comment
Open

Is it possible to know if LuaBridge called my code #295

rpatters1 opened this issue Sep 5, 2022 · 1 comment

Comments

@rpatters1
Copy link
Contributor

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
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant