diff --git a/Source/LuaBridge/detail/Invoke.h b/Source/LuaBridge/detail/Invoke.h index 6a4415e5..ed383774 100644 --- a/Source/LuaBridge/detail/Invoke.h +++ b/Source/LuaBridge/detail/Invoke.h @@ -102,6 +102,11 @@ class LuaResult return LuaRef(m_L); } + + /** + * @brief Get the Lua state for this result. + */ + lua_State * state() const { return m_L; } #if LUABRIDGE_HAS_EXCEPTIONS /** @@ -177,6 +182,13 @@ class LuaResult std::variant, std::string> m_data; }; +inline LuaException::LuaException(const LuaResult& result) + : m_L(result.state()) + , m_code(result.errorCode()) + , m_what(result.errorMessage()) +{ +} + //================================================================================================= /** * @brief Safely call Lua code. diff --git a/Source/LuaBridge/detail/LuaException.h b/Source/LuaBridge/detail/LuaException.h index 626b5156..ebfc1907 100644 --- a/Source/LuaBridge/detail/LuaException.h +++ b/Source/LuaBridge/detail/LuaException.h @@ -17,6 +17,8 @@ namespace luabridge { +class LuaResult; + //================================================================================================ class LuaException : public std::exception { @@ -32,6 +34,11 @@ class LuaException : public std::exception , m_code(code) { } + + /** + * @brief Construct a LuaException from a LuaResult. + */ + LuaException(const LuaResult& result); ~LuaException() noexcept override {