Module:Error
Documentation for this module may be created at Module:Error/doc
local p = {}
-- Call this in modules
function p.error(message, tagname)
-- message shouldn't be nil nor empty
if message == nil then
error("no message specified", 2)
else
message = mw.text.trim(tostring(message))
if message == "" then
error("empty message", 2)
end
end
if type(tagname) ~= "string" then
tagname = "strong"
else
tagname = mw.ustring.lower(tagname)
if tagname ~= "span" and tagname ~= "p" and tagname ~= "div" then
tagname = "strong"
end
end
return tostring(mw.html.create(tagname)
:addClass("error")
:wikitext(message))
end
-- Call this in templates
function p.main(frame)
return p.error(
frame.args[1] or frame:getParent().args[1],
frame.args.tag or frame:getParent().args.tag
)
end
return p