• Automatically run a trace on an lua error?
    7 replies, posted
I'm trying to troubleshoot a clientside error right now. Unhelpfully, gmod reports it as occuring in lua\includes\util.lua:130, saying that self is a nil value. Frankly, telling me that an error is occuring in one of the standard and well-tested gmod lua libraries doesn't help me very much. Is there some sort of console command that can cause errors like these to automatically dump a trace in the console?
override function, add debug.Trace()
[QUOTE=Wizard of Ass;36254116]override function, add debug.Trace()[/QUOTE] So, since line 130 was within the AccessorFunc function, I could simply created a new function named AccessorFunc, call debug.Trace(), and everything would be fine?
Make sure you're still calling AccessorFunc's original function though. [lua] local oldAccessorFunc = AccessorFunc; function AccessorFunc(object, variable, name, force) oldAccessorFunc(object, variable, name, force); debug.Trace(); end; [/lua]
Also, there is a automatic trace in gmod 13.
Awesome, thanks for the help everyone!
redefine functions in _G with Chessnuts tactic if you want it everywhere on global functions.. never done so before, no idea what'll happen
[lua] local function debugTable(info) for k, v in pairs(info) do if (type(v) == "function") then _G["stored"..k] = v; _G[k] = function(...) _G["stored"..k](...); debug.Trace(); end; elseif (type(v) == "table") then for k2, v2 in pairs(v) do debugTable(v2); end; end; end; end; debugTable(_G); [/lua] Haven't tested.
Sorry, you need to Log In to post a reply to this thread.