<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://linguifex.com/w/index.php?action=history&amp;feed=atom&amp;title=Module%3Alanguages%2Ferror</id>
	<title>Module:languages/error - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://linguifex.com/w/index.php?action=history&amp;feed=atom&amp;title=Module%3Alanguages%2Ferror"/>
	<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:languages/error&amp;action=history"/>
	<updated>2026-05-24T08:43:52Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>https://linguifex.com/w/index.php?title=Module:languages/error&amp;diff=524079&amp;oldid=prev</id>
		<title>Sware: Created page with &quot;--[=[ Throw an error for an invalid language code or script code.  `code` (required) is the bad code and can be nil or a non-string.  `param` (required) is the name of the parameter in which the code was contained. It can be a string, a number (for a 	numeric param, in which case the param will show up in the error message as an ordinal such as &quot;first&quot; or &quot;second&quot;), 	or `true` if no parameter can be clearly identified. It can also be a function of one argument (an error...&quot;</title>
		<link rel="alternate" type="text/html" href="https://linguifex.com/w/index.php?title=Module:languages/error&amp;diff=524079&amp;oldid=prev"/>
		<updated>2026-05-13T10:39:41Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;--[=[ Throw an error for an invalid language code or script code.  `code` (required) is the bad code and can be nil or a non-string.  `param` (required) is the name of the parameter in which the code was contained. It can be a string, a number (for a 	numeric param, in which case the param will show up in the error message as an ordinal such as &amp;quot;first&amp;quot; or &amp;quot;second&amp;quot;), 	or `true` if no parameter can be clearly identified. It can also be a function of one argument (an error...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--[=[&lt;br /&gt;
Throw an error for an invalid language code or script code.&lt;br /&gt;
&lt;br /&gt;
`code` (required) is the bad code and can be nil or a non-string.&lt;br /&gt;
&lt;br /&gt;
`param` (required) is the name of the parameter in which the code was contained. It can be a string, a number (for a&lt;br /&gt;
	numeric param, in which case the param will show up in the error message as an ordinal such as &amp;quot;first&amp;quot; or &amp;quot;second&amp;quot;),&lt;br /&gt;
	or `true` if no parameter can be clearly identified. It can also be a function of one argument (an error message) or&lt;br /&gt;
	two arguments (an error message and a number of stack frames to ignore, same as in the error() function itself), in&lt;br /&gt;
	which case the function will be called with the same error message as if `true` were passed in. (This is useful e.g.&lt;br /&gt;
	when parsing inline modifiers, where the parameter name may not be available or may not be so clearly identifiable,&lt;br /&gt;
	but an error function is often available.)&lt;br /&gt;
&lt;br /&gt;
`code_desc` (optional) is text describing what the code is; by default, &amp;quot;language code&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
`template_text` (optional) is a string specifying the template that generated the error, or a function&lt;br /&gt;
	to generate this string. If given, it will be displayed in the error message.&lt;br /&gt;
]=]&lt;br /&gt;
&lt;br /&gt;
local dump = mw.dumpObject&lt;br /&gt;
&lt;br /&gt;
local function internal_err(param, types, param_type)&lt;br /&gt;
	error((&amp;quot;Internal error: the parameter %s must be %s, but received %s&amp;quot;):format(dump(param), types, param_type))&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return function(code, param, code_desc, template_tag)&lt;br /&gt;
	local is_callable = require(&amp;quot;Module:fun&amp;quot;).is_callable&lt;br /&gt;
&lt;br /&gt;
	if param == nil then&lt;br /&gt;
		param = true&lt;br /&gt;
	end&lt;br /&gt;
	if not code_desc then&lt;br /&gt;
		code_desc = &amp;quot;language code&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if template_tag then&lt;br /&gt;
		if is_callable(template_tag) then&lt;br /&gt;
			template_tag = template_tag()&lt;br /&gt;
		else&lt;br /&gt;
			local template_tag_type = type(template_tag)&lt;br /&gt;
			if template_tag_type ~= &amp;quot;string&amp;quot; then&lt;br /&gt;
				internal_err(&amp;quot;template_tag&amp;quot;, &amp;quot;a function, callable table or nil&amp;quot;, &amp;quot;a &amp;quot; .. template_tag_type)&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
		template_tag = (&amp;quot; (original template: %s)&amp;quot;):format(template_tag)&lt;br /&gt;
	else&lt;br /&gt;
		template_tag = &amp;quot;&amp;quot;&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	local param_is_callable = is_callable(param)&lt;br /&gt;
	local function err(msg)&lt;br /&gt;
		msg = msg .. template_tag&lt;br /&gt;
		if not(param_is_callable) then&lt;br /&gt;
			error(require(&amp;quot;Module:string utilities&amp;quot;).ucfirst(msg) .. &amp;quot;.&amp;quot;, 3)&lt;br /&gt;
		end&lt;br /&gt;
		param(msg, 3)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	if not (param == true or param_is_callable) then&lt;br /&gt;
		local param_type = type(param)&lt;br /&gt;
		if not (param_type == &amp;quot;string&amp;quot; or param_type == &amp;quot;number&amp;quot;) then&lt;br /&gt;
			internal_err(&amp;quot;param&amp;quot;, &amp;quot;a number, string, function, callable table, true or nil&amp;quot;, param == false and &amp;quot;false&amp;quot; or &amp;quot;a &amp;quot; .. param_type)&lt;br /&gt;
		end&lt;br /&gt;
		param = (&amp;quot;parameter %s &amp;quot;):format(dump(param))&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	if code == nil or code == &amp;quot;&amp;quot; then&lt;br /&gt;
		if param == true or param_is_callable then&lt;br /&gt;
			err(code_desc .. &amp;quot; is missing&amp;quot;)&lt;br /&gt;
		else&lt;br /&gt;
			err(param .. &amp;quot;(&amp;quot; .. code_desc .. &amp;quot;) is missing&amp;quot;)&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		local code_type = type(code)&lt;br /&gt;
		if code_type ~= &amp;quot;string&amp;quot; then&lt;br /&gt;
			internal_err(&amp;quot;code&amp;quot;, &amp;quot;a string or nil&amp;quot;, &amp;quot;a &amp;quot; .. code_type)&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	err((&amp;quot;%smust be a valid %s; the value %s is not valid (see [[Wiktionary:List of languages]])&amp;quot;):format(&lt;br /&gt;
		(param == true or param_is_callable) and &amp;quot;&amp;quot; or param, code_desc, dump(code)&lt;br /&gt;
	))&lt;br /&gt;
end&lt;/div&gt;</summary>
		<author><name>Sware</name></author>
	</entry>
</feed>