2023-04-09 05:35:35 +00:00
|
|
|
-- SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2022-04-01 12:51:01 +00:00
|
|
|
---@diagnostic disable: lowercase-global
|
|
|
|
inspect = require "inspect"
|
2023-04-20 20:29:52 +00:00
|
|
|
dbg = require "debugger"
|
2022-04-01 12:51:01 +00:00
|
|
|
|
2023-06-16 02:56:33 +00:00
|
|
|
function PrintWhere()
|
|
|
|
local info = debug.getinfo(2)
|
|
|
|
local name = info.name
|
|
|
|
local line = info.currentline
|
|
|
|
local namewhat = info.namewhat
|
|
|
|
local shortsrc = info.short_src
|
|
|
|
if (namewhat == "method") and
|
|
|
|
(shortsrc ~= "[C]") and
|
|
|
|
(not string.find(shortsrc, "/lib")) then
|
|
|
|
print(shortsrc .. ":" .. line .. ": " .. name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
--debug.sethook(PrintWhere, "l")
|
|
|
|
|
|
|
|
function Traceback()
|
|
|
|
print(debug.traceback())
|
|
|
|
end
|
|
|
|
|
|
|
|
local msgh = function(err)
|
2023-10-27 14:53:25 +00:00
|
|
|
fk.qCritical(err .. "\n" .. debug.traceback(nil, 2))
|
2023-06-16 02:56:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function Pcall(f, ...)
|
|
|
|
local ret = { xpcall(f, msgh, ...) }
|
|
|
|
local err = table.remove(ret, 1)
|
|
|
|
if err ~= false then
|
|
|
|
return table.unpack(ret)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-04-01 12:51:01 +00:00
|
|
|
function p(v) print(inspect(v)) end
|
2023-04-20 20:29:52 +00:00
|
|
|
function pt(t) for k, v in pairs(t) do print(k, v) end end
|