Skip to content
Snippets Groups Projects
Commit c09d370d authored by DarkGod's avatar DarkGod
Browse files

better error report to spot evil addons

parent d1aead8e
No related branches found
Tags tome-1.6.4
No related merge requests found
Pipeline #
......@@ -43,6 +43,7 @@ function _M:init(errs)
addons[#addons+1] = name.."-"..data.version_txt..extra
end
table.insert(errs, 2, "Addons: "..table.concat(addons, ", ").."\n")
self.errs_t = errs
errs = table.concat(errs, "\n")
self.errs = errs
Dialog.init(self, "Lua Error", 700, 500)
......@@ -127,8 +128,20 @@ function _M:saveError(seen, reported)
end
function _M:send()
local errs = self.errs_t
for i, line in ripairs(errs) do pcall(function()
local _, _, file = line:find("(/.*.lua):%d+")
if file then
local sep = fs.getPathSeparator()
local rpath = fs.getRealPath(file)
table.insert(errs, i+1, " =from= "..(rpath:gsub("^.*"..sep.."game"..sep, "")))
end
end) end
errs = table.concat(errs, "\n")
print(errs)
game:unregisterDialog(self)
profile:sendError(self.what.text, self.errs)
profile:sendError(self.what.text, errs)
game.log("#YELLOW#Error report sent, thank you.")
self:saveError(true, true)
end
......@@ -2852,7 +2852,13 @@ function util.send_error_backtrace(msg)
while true do
local stacktrace = debug.getinfo(level, "nlS")
if stacktrace == nil then break end
errs[#errs+1] = ((" function: %s (%s) at %s:%d"):format(stacktrace.name or "???", stacktrace.what, stacktrace.source or stacktrace.short_src or "???", stacktrace.currentline))
local src = stacktrace.source or stacktrace.short_src or "???"
errs[#errs+1] = ((" function: %s (%s) at %s:%d"):format(stacktrace.name or "???", stacktrace.what, src, stacktrace.currentline))
if src:prefix("@") then pcall(function()
local rpath = fs.getRealPath(src:sub(2))
local sep = fs.getPathSeparator()
if rpath then errs[#errs+1] = ((" =from= %s"):format(rpath:gsub("^.*"..sep.."game"..sep, ""))) end
end) end
level = level + 1
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment