Module:Error
Jump to navigation
Jump to search
Documentation [edit]
This module is used to display error messages in a consistent way and categorize pages that have them. See Template:Error for how to use this template in wikitext. For modules, see below.
Usage
local err = require('Module:Error').call
return err('error message', 'type')
This displays: error message
Parameters
- The first parameter is the text of the message to display. Must be a string. Highly recommended; the default message just says an error occurred in a script.
- The second parameter is the type of error, which determines the categorization. Must be a string. The default is "script". This will add the page to Category:Pages with script errors.
The above documentation is transcluded from Module:Error/doc.
local p = {}
--To be called by templates
function p.main(frame)
local args = frame:getParent().args
if not args['type'] or mw.text.trim(args['type']) == '' then
args['type'] = 'template'
end
return p.call(args[1], args['type'])
end
--To be called by modules
function p.call(message, errType)
if not errType or mw.text.trim(errType) == '' then
errType = 'script'
else
errType = mw.ustring.lower(errType)
end
if not message or mw.text.trim(message) == '' then
message = 'An error occurred (' .. errType .. ')'
end
local category = '[' .. '[' .. 'Category:Pages with ' .. errType .. ' errors]]'
return '<span class="error">' .. message .. '</span>' .. category
end
return p