MCPcopy Create free account
hub / github.com/Tencent/UnLua / ReportLuaCallError

Function ReportLuaCallError

Plugins/UnLua/Source/UnLua/Private/UnLuaBase.cpp:151–181  ·  view source on GitHub ↗

* Report Lua error */

Source from the content-addressed store, hash-verified

149 * Report Lua error
150 */
151 int32 ReportLuaCallError(lua_State *L)
152 {
153 if (FUnLuaDelegates::ReportLuaCallError.IsBound())
154 {
155 return FUnLuaDelegates::ReportLuaCallError.Execute(L); // developers can provide error reporter themselves
156 }
157
158 int32 Type = lua_type(L, -1);
159 if (Type == LUA_TSTRING)
160 {
161 const char *ErrorString = lua_tostring(L, -1);
162 luaL_traceback(L, L, ErrorString, 1);
163 ErrorString = lua_tostring(L, -1);
164 UE_LOG(LogUnLua, Error, TEXT("Lua error message: %s"), UTF8_TO_TCHAR(ErrorString));
165 }
166 else if (Type == LUA_TTABLE)
167 {
168 // multiple errors is possible
169 int32 MessageIndex = 0;
170 lua_pushnil(L);
171 while (lua_next(L, -2) != 0)
172 {
173 const char *ErrorString = lua_tostring(L, -1);
174 UE_LOG(LogUnLua, Error, TEXT("Lua error message %d : %s"), MessageIndex++, UTF8_TO_TCHAR(ErrorString));
175 lua_pop(L, 1);
176 }
177 }
178
179 lua_pop(L, 1);
180 return 0;
181 }
182
183 /**
184 * Push a pointer with the name of meta table

Callers 3

LoadBufferMethod · 0.85
LoadChunkFunction · 0.85
RunChunkFunction · 0.85

Calls 6

lua_typeFunction · 0.85
luaL_tracebackFunction · 0.85
lua_pushnilFunction · 0.85
lua_nextFunction · 0.85
ExecuteMethod · 0.80
IsBoundMethod · 0.45

Tested by

no test coverage detected