Anonymous user
Module:Protection banner: Difference between revisions
produce wikitext errors rather than script errors for errors caused by invalid user input
(use mw.ustring.lower to convert the reason to lower case, for the benefit of other-language wikis) |
(produce wikitext errors rather than script errors for errors caused by invalid user input) |
||
Line 15:
-- Helper functions
--------------------------------------------------------------------------------
local function makeWikitextError(msg)
-- @TODO: localise this.
local boilerplate = 'Error: $1 ([[Module:Protection banner#Errors|help]])'
local errorText = mw.message.newRawMessage(boilerplate):params(msg):plain()
return string.format(
'<strong class="error">%s</strong>',
errorText
)
end
local function makeCategoryLink(cat)
Line 42 ⟶ 52:
dateType,
tostring(dateString)
), 0)
end
Line 84 ⟶ 94:
self.action = args.action
else
error(string.format(
'invalid action ("%s")',
tostring(args.action)
), 0)
end
Line 800 ⟶ 813:
end
-- Initialise the protection object and
local protectionObjCreated, protectionObj =
Protection.new, Protection, -- equivalent to Protection:new()
args,
cfg,
title
)
if not protectionObjCreated then
-- protectionObj is the error message.
return makeWikitextError(protectionObj)
end
-- Initialise the blurb object
local blurbObj = Blurb:new(protectionObj, args, cfg)
|