chore: upgrade ts2lua-unreal to v0.3.1 with lowercase lib/module.lua & lib/class.lua and commit framework refactor
This commit is contained in:
1 parent
783dccf53d
commit
3572f2da43
206 files changed
+14442
-13186
No files matched your search
@@ -0,0 +1,62 @@
|
||||
local ____exports = __module.env
|
||||
---
|
||||
-- @module_data
|
||||
local activeHandler = nil
|
||||
function ____exports.SetupTracebackHandler(handler)
|
||||
activeHandler = handler
|
||||
end
|
||||
local function DefaultDump(msg)
|
||||
if UnLua ~= nil and UnLua.LogError ~= nil then
|
||||
UnLua.LogError(msg)
|
||||
else
|
||||
print("[ERROR] " .. msg)
|
||||
end
|
||||
end
|
||||
local function OnError(err)
|
||||
local errText = tostring(err)
|
||||
local fullStack = debug.traceback(errText, 2)
|
||||
if activeHandler ~= nil then
|
||||
if activeHandler.LogTraceback ~= nil then
|
||||
pcall(activeHandler.LogTraceback, errText, fullStack)
|
||||
end
|
||||
if activeHandler.DumpTraceback ~= nil then
|
||||
pcall(activeHandler.DumpTraceback, fullStack)
|
||||
else
|
||||
DefaultDump(fullStack)
|
||||
end
|
||||
else
|
||||
DefaultDump(fullStack)
|
||||
end
|
||||
return fullStack
|
||||
end
|
||||
--- 带完整堆栈上报的安全调用(对应 gamelogic 的 tbpcall),保留全部多返回值。
|
||||
function ____exports.tbpcall(fn, ...)
|
||||
return xpcall(fn, OnError, ...)
|
||||
end
|
||||
--- 调用带 self 的对象方法并捕获异常上报堆栈。
|
||||
function ____exports.tbpcallMethod(fn, selfObj, ...)
|
||||
return xpcall(fn, OnError, selfObj, ...)
|
||||
end
|
||||
function ____exports.ReportError(message)
|
||||
OnError(message)
|
||||
end
|
||||
function __module.StashData(env, to)
|
||||
local ____has = to.__has__
|
||||
if not ____has then
|
||||
____has = {}
|
||||
to.__has__ = ____has
|
||||
end
|
||||
to.activeHandler = activeHandler
|
||||
____has.activeHandler = true
|
||||
end
|
||||
function __module.RestoreData(env, from)
|
||||
local ____has = from.__has__
|
||||
if not ____has then
|
||||
return
|
||||
end
|
||||
if ____has.activeHandler then
|
||||
activeHandler = from.activeHandler
|
||||
end
|
||||
end
|
||||
function __module.UpdateImports()
|
||||
end
|
||||
Reference in new issue
Block a user