FANDOM


--[[ //Helps debug lua modules using console by creating a pseudo frame 
and other useful functions
Syntax:
require("Module:debug").frame(childtable, parenttable)
Example:
frame = require("Module:debug").frame({'aaa','sss'},{'zz'=8,'1'})
p.main(frame)
Todo:
Add more debugging tools ]]--
 
local p = {}
local dumpObj = require('Dev:Inspect').inspect
 
-- e.g. {"abc","zz"} parameters from a page calling this module directly
function p.frame(args, pArgs)
    local frameTools = require("Dev:FrameTools")
 
    return frameTools.makePseudoFrame(nil, args, pArgs)
end
 
-- Generates a tracebackfor a function
-- ex. function fFunction() x=1 +c end ; p.trace(fFunction, var1,var2)
function p.trace(errFunction, ...)
    local function testFunc ()
         return errFunction(unpack(arg))
    end
 
    local success, result = xpcall(testFunc,
        function(err) 
            mw.log(debug.traceback(err) )
            return debug.traceback(err) 
        end)
 
    return success, result
end 
 
-- Outputs the information from a obj (readable table, string, number, etc)
function p.log(obj)
    return dumpObj(obj)
end
 
return p

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.