Module:Protect: Difference between revisions

137 bytes removed ,  6 years ago
Tweak errFormat behavior
(New module)
 
(Tweak errFormat behavior)
Line 1: Line 1:
local function wrapMessage(errMessage)
return '<span class="error">' .. errMessage .. '</span>'
end
local defaultFormat = wrapMessage('Error: %s')
local function processResult(errFormat, success, ...)
local function processResult(errFormat, success, ...)
if not success then
if not success then
Line 13: Line 7:


local function protect(func, errFormat, raw)
local function protect(func, errFormat, raw)
if not errFormat then
errFormat = errFormat or 'Error: %s'
errFormat = defaultFormat
if not raw then
elseif not raw then
errFormat = '<strong class="error">' .. errFormat .. '</strong>'
errFormat = wrapMessage(errFormat)
end
end
Anonymous user