Module:Error

local p = {}

local utilsError = require("Module:UtilsError")

local Constants = mw.loadData("Module:Constants/Data")

local DEFAULT_WARN_MESSAGE = "An error occurred" local CATEGORY_ERRORS = "Category:"..Constants.category.templateErrors

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

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

function p.printError(message, category, nowarn) local errorCategory = category or CATEGORY_ERRORS if not nowarn then utilsError.warn(message or DEFAULT_WARN_MESSAGE) end return utilsError.error(message, ":"..errorCategory)..""..errorCategory.."" end

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

return p