Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Source/LuaBridge/detail/Invoke.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
/**
Expand Down Expand Up @@ -177,6 +182,13 @@ class LuaResult
std::variant<std::vector<LuaRef>, 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.
Expand Down
7 changes: 7 additions & 0 deletions Source/LuaBridge/detail/LuaException.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

namespace luabridge {

class LuaResult;

//================================================================================================
class LuaException : public std::exception
{
Expand All @@ -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
{
Expand Down