1
0
Fork 0

Errors in Lua don't include the error handler in the stack trace.

Fixes #817.
This commit is contained in:
madmaxoft 2014-03-19 22:55:47 +01:00
parent d6a72da382
commit 74b7f51b89
2 changed files with 7 additions and 7 deletions

View File

@ -1080,20 +1080,20 @@ bool cLuaState::ReportErrors(lua_State * a_LuaState, int a_Status)
void cLuaState::LogStackTrace(void)
void cLuaState::LogStackTrace(int a_StartingDepth)
{
LogStackTrace(m_LuaState);
LogStackTrace(m_LuaState, a_StartingDepth);
}
void cLuaState::LogStackTrace(lua_State * a_LuaState)
void cLuaState::LogStackTrace(lua_State * a_LuaState, int a_StartingDepth)
{
LOGWARNING("Stack trace:");
lua_Debug entry;
int depth = 0;
int depth = a_StartingDepth;
while (lua_getstack(a_LuaState, depth, &entry))
{
lua_getinfo(a_LuaState, "Sln", &entry);
@ -1312,7 +1312,7 @@ void cLuaState::LogStack(lua_State * a_LuaState, const char * a_Header)
int cLuaState::ReportFnCallErrors(lua_State * a_LuaState)
{
LOGWARNING("LUA: %s", lua_tostring(a_LuaState, -1));
LogStackTrace(a_LuaState);
LogStackTrace(a_LuaState, 1);
return 1; // We left the error message on the stack as the return value
}

View File

@ -868,10 +868,10 @@ public:
static bool ReportErrors(lua_State * a_LuaState, int status);
/** Logs all items in the current stack trace to the server console */
void LogStackTrace(void);
void LogStackTrace(int a_StartingDepth = 0);
/** Logs all items in the current stack trace to the server console */
static void LogStackTrace(lua_State * a_LuaState);
static void LogStackTrace(lua_State * a_LuaState, int a_StartingDepth = 0);
/** Returns the type of the item on the specified position in the stack */
AString GetTypeText(int a_StackPos);