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

Create custom luabridge exceptions #120

Open
kunitoki opened this issue Apr 17, 2023 · 2 comments
Open

Create custom luabridge exceptions #120

kunitoki opened this issue Apr 17, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@kunitoki
Copy link
Owner

To be able to catch individual exceptions when raised by luabridge, we should create specific derived exception types.

@kunitoki kunitoki added enhancement New feature or request RFC labels Apr 17, 2023
@rpatters1
Copy link
Contributor

This seems like a reasonable step to me. I would suggest that it derive from std::runtime_error.

As a side note, I went looking to see how it would differ from LuaException and discovered this:

inline void enableExceptions(lua_State* L) noexcept
{
#if LUABRIDGE_HAS_EXCEPTIONS
    LuaException::enableExceptions(L);
#else
    unused(L);

    LUABRIDGE_ASSERT(false); // Never call this function when exceptions are not enabled.
#endif
}

Would it not be safer to do it this way? (Thinking about the principal of failing early, this would fail at compile time rather than run time.):

#if LUABRIDGE_HAS_EXCEPTIONS
inline void enableExceptions(lua_State* L) noexcept
{
    LuaException::enableExceptions(L);
}
#endif

@kunitoki
Copy link
Owner Author

Yes makes sense

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

No branches or pull requests

2 participants