* Report Lua error */
| 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 |
no test coverage detected