Module:UserLinks: Difference between revisions

From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
add links to error help sections
(check for demo == 'yes' rather than just its existence)
(add links to error help sections)
Line 7:
 
-- Define a custom error message for this module.
local function err(msg, section)
local help
if section then
help = ' ([[Template:User-multi#' .. section .. '|help]])'
else
help = ''
end
local cat
if demo == 'yes' then
Line 14 ⟶ 20:
cat = '[[Category:UserLinks transclusions with errors]]'
end
return '<span class="error">[[ModuleTemplate:UserLinksUser-multi|User-multi]] error: ' .. msg .. '.</span>' .. cat
.. help .. '.</span>' .. cat
end
 
Line 185 ⟶ 192:
end
if not linkNumber then
return err('"' .. linktype .. '" is not a valid link code', 'Not a valid link code')
end
local result = linktypes[linkNumber][2]()
if type(result) ~= 'string' then
return err('the function for code "' .. linktype .. '" did not return a string value')
'the function for code "' .. linktype .. '" did not return a string value',
'Function did not return a string value'
)
end
return result
Line 231 ⟶ 241:
-- If the username is absent or blank, return an error and a tracking category.
if args.user == '' or (not args.user and (not args.User or args.User == '')) then
return err('no username detected', 'No username detected')
else
u.username = args.user or args.User
Line 239 ⟶ 249:
u.project = args.Project or args.project
u.lang = args.lang or args.Lang
if u.lang and not mw.language.isKnownLanguageTag(u.lang) then
if mw.language.isKnownLanguageTag(u.lang) then
return err('"' .. u.lang .. '" is not a valid language code')
table.insert(trackingCategories, '[[Category:UserLinks transclusions with language parameters]]')
else
return err('"' .. u.lang .. '" is not a valid language code', 'Not a valid language code')
end
end
Line 283 ⟶ 297:
)
else
return err('"' .. u.project .. '" is not a valid interwiki prefix')
'"' .. u.project .. '" is not a valid interwiki prefix',
'Not a valid interwiki prefix'
)
end
else
return err('"' .. u.project .. '" is not a valid interwiki prefix')
'"' .. u.project .. '" is not a valid interwiki prefix',
'Not a valid interwiki prefix'
)
end
end
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu