Module:Error

local utilsError = require("Module:UtilsError")

local p = {}

local DEFAULT_ERROR_MESSAGE = "Error" local CATEGORY_ERRORS = "Category:Pages with template errors"

function p.Error(frame) local args = frame.args return p.printError(args[1], args[2]) end

function p.Warn(frame) local args = frame.args return p.warn(args[1], args[2]) end

-- Should maybe be moved to Module:UtilsError function p.printError(message, category, nowarn) local errorMessage = message and ("Error: " .. message) or DEFAULT_ERROR_MESSAGE local errorCategory = category or CATEGORY_ERRORS if not nowarn then utilsError.warn(message or DEFAULT_ERROR_MESSAGE) end local err = mw.html.create("strong") :addClass("error") :wikitext(errorMessage) return string.format("%s%s", errorCategory, tostring(err), errorCategory) end

function p.warn(message, category) utilsError.warn(message or "") return string.format("%s", category or CATEGORY_ERRORS) end

return p