LuaBridge3
LuaBridge3 copied to clipboard
Create custom luabridge exceptions
To be able to catch individual exceptions when raised by luabridge, we should create specific derived exception types.
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
Yes makes sense