Module:UtilsError

local p = {}

function p.warn(msg, traceBack, omitFrames) omitFrames = omitFrames or 0 local errorSource local invokeFrame = "" .. mw.getCurrentFrame:getParent:getTitle .. "" msg = msg .. "\n" if traceBack ~= false then local callStack = debug.traceback("", 2) msg = msg .. "\n" for line in string.gmatch(callStack, "\tModule:[^:]*:[^\n]*\n") do			if omitFrames ~= 0 then omitFrames = omitFrames - 1 else line = string.gsub(line, "\tModule:([^:]*):(.*)", "::Module:%1:%2") msg = msg .. line .. "\n" end end msg = msg .. "::" .. invokeFrame .. "\n" end mw.addWarning(msg) end

p.Schemas = { warn = { msg = { type = "string", required = true, desc = "Warning message to log above the edit preview area", },		traceback = { type = "boolean", desc = "If true or nil, prints a stack trace of all module frames, plus the invoking frame (usually a template).", },		omitFrames = { type = "number", desc = "Number of additional frames to omit from the stack trace." }	} }

p.Documentation = { {		name = "warn", params = {"msg", "traceback", "omitFrames"}, returns = "Returns nil, but logs the above message, possibly with a stack trace. Preview this page for an example of output.", cases = { {				args = { "I AM ERROR" }, },			{				args = { "I AM ERROR", false }, }		},	}, }

return p