Module:Utils: Difference between revisions

From Halopedia, the Halo wiki

No edit summary
(Undo revision 1372824 by Dab1001 (talk))
Tag: Undo
Line 2: Line 2:


function utils.error( ... )
function utils.error( ... )
return mw.dumpObject( ... )
end --[=[
-- Collect necessary information to display error
-- Collect necessary information to display error
local args = select( 'args', ... )
local message = select( 1, ... ) or 'There was an error with a template. Are the parameters all correct?'
local message = args[1] or 'There was an error with a template. Are the parameters all correct?'
local etype = select( 2, ... ) or 'Template'
local etype = args[2] or 'Template'
local category = select( 3, ... ) or 'Pages containing template errors'
local category = args[3] or 'Pages containing template errors'
local template = select( 4, ... ) or nil
local template = args[4] or nil
-- Add a warning to the edit preview
-- Add a warning to the edit preview
if template == nil then
if template == nil then
Line 23: Line 24:
.. ']]'
.. ']]'
end
end
 
]=]
return utils
return utils

Revision as of 15:57, September 28, 2020

Documentation for this module may be created at ModuleDoc:Utils

local utils = {}

function utils.error( ... )
	return mw.dumpObject( ... )
	end --[=[
	-- Collect necessary information to display error
	local message = select( 1, ... ) or 'There was an error with a template. Are the parameters all correct?'
	local etype = select( 2, ... ) or 'Template'
	local category = select( 3, ... ) or 'Pages containing template errors'
	local template = select( 4, ... ) or nil
	-- Add a warning to the edit preview
	if template == nil then
		mw.addWarning( etype .. ' error: ' .. message )
	else
		mw.addWarning( etype .. ' error: ' .. message .. ' (Template name: "' .. template .. ')' )
	end
	-- Create and return the text to display on the page itself
	return [[<span class="template-error" style="color: red;">'''{{uc:]]
		.. etype
		.. [[ error:}}''' ]]
		.. message
		.. '</span> [[Category:'
		.. category
		.. ']]'
end
]=]
return utils