<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://dgrwiki.org/index.php?action=history&amp;feed=atom&amp;title=Module%3AProtect%2Fdoc</id>
	<title>Module:Protect/doc - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://dgrwiki.org/index.php?action=history&amp;feed=atom&amp;title=Module%3AProtect%2Fdoc"/>
	<link rel="alternate" type="text/html" href="https://dgrwiki.org/index.php?title=Module:Protect/doc&amp;action=history"/>
	<updated>2026-04-23T06:49:30Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://dgrwiki.org/index.php?title=Module:Protect/doc&amp;diff=574&amp;oldid=prev</id>
		<title>Taurussmith: Protected &quot;Module:Protect/doc&quot; ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)) [cascading]</title>
		<link rel="alternate" type="text/html" href="https://dgrwiki.org/index.php?title=Module:Protect/doc&amp;diff=574&amp;oldid=prev"/>
		<updated>2026-03-13T00:31:50Z</updated>

		<summary type="html">&lt;p&gt;Protected &amp;quot;&lt;a href=&quot;/wiki/Module:Protect/doc&quot; title=&quot;Module:Protect/doc&quot;&gt;Module:Protect/doc&lt;/a&gt;&amp;quot; ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)) [cascading]&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 00:31, 13 March 2026&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Taurussmith</name></author>
	</entry>
	<entry>
		<id>https://dgrwiki.org/index.php?title=Module:Protect/doc&amp;diff=573&amp;oldid=prev</id>
		<title>Taurussmith: Created page with &quot;{{Module rating|protected}} {{used in system}} This metamodule simplifies error handling in other modules. It transforms a function, which may throw an error, into a function, which returns a specified error message in that case.  == Usage == &lt;syntaxhighlight lang=&quot;lua&quot;&gt;  local protect = require(&#039;Module:Protect&#039;)  local protectedFunc = protect(func, errFormat, options) &lt;/syntaxhighlight&gt; === Arguments ===  * &#039;&#039;{{code|func}}&#039;&#039; *: Function to be tr...&quot;</title>
		<link rel="alternate" type="text/html" href="https://dgrwiki.org/index.php?title=Module:Protect/doc&amp;diff=573&amp;oldid=prev"/>
		<updated>2026-03-13T00:30:58Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{Module rating|protected}} {{used in system}} This &lt;a href=&quot;/index.php?title=Help:Lua_metamodules&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;Help:Lua metamodules (page does not exist)&quot;&gt;metamodule&lt;/a&gt; simplifies error handling in other modules. It transforms a function, which may throw an error, into a function, which returns a specified error message in that case.  == Usage == &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;  local protect = require(&amp;#039;Module:Protect&amp;#039;)  local protectedFunc = protect(func, errFormat, options) &amp;lt;/syntaxhighlight&amp;gt; === Arguments ===  * &amp;#039;&amp;#039;{{code|func}}&amp;#039;&amp;#039; *: Function to be tr...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Module rating|protected}}&lt;br /&gt;
{{used in system}}&lt;br /&gt;
This [[Help:Lua metamodules|metamodule]] simplifies error handling in other modules. It transforms a function, which may throw an error, into a function, which returns a specified error message in that case.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
 local protect = require(&amp;#039;Module:Protect&amp;#039;)&lt;br /&gt;
 local protectedFunc = protect(func, errFormat, options)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
=== Arguments ===&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;{{code|func}}&amp;#039;&amp;#039;&lt;br /&gt;
*: Function to be transformed.&lt;br /&gt;
* &amp;#039;&amp;#039;{{code|errFormat}}&amp;#039;&amp;#039; (default: {{code|&amp;#039;Error: %s&amp;#039;}})&lt;br /&gt;
*: Custom error message.&lt;br /&gt;
*: Use {{code|&amp;#039;%s&amp;#039;}} to include the message from a caught error.&lt;br /&gt;
* &amp;#039;&amp;#039;{{code|options}}&amp;#039;&amp;#039; – optional table with the following fields:&lt;br /&gt;
** {{code|raw}} (default: false)&lt;br /&gt;
**: If true, then &amp;#039;&amp;#039;{{code|errFormat}}&amp;#039;&amp;#039; will be used as is, otherwise it will be wrapped inside a tag &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;lt;strong class=&amp;quot;error&amp;quot;&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;.&lt;br /&gt;
** {{code|removeLocation}} (default: true)&lt;br /&gt;
**: If true, removes location information from caught error messages.&lt;br /&gt;
&lt;br /&gt;
=== Return value ===&lt;br /&gt;
&lt;br /&gt;
The resulting {{code|protectedFunc}} is a &amp;#039;&amp;#039;function&amp;#039;&amp;#039;, which calls the original function &amp;#039;&amp;#039;{{code|func}}&amp;#039;&amp;#039;, passing all arguments to it, and returns all its return values. If &amp;#039;&amp;#039;{{code|func}}&amp;#039;&amp;#039; throws an error, the specified error message is returned instead.&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local protect = require(&amp;#039;Module:Protect&amp;#039;)&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
    if not frame.args[1] then&lt;br /&gt;
        error(&amp;#039;missing argument&amp;#039;)&lt;br /&gt;
    end&lt;br /&gt;
    return frame.args[1]&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
p.main = protect(p.main)&lt;br /&gt;
&lt;br /&gt;
return p&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Invoking the main function without arguments will output: &amp;lt;strong class=&amp;quot;error&amp;quot;&amp;gt;Error: missing argument&amp;lt;/strong&amp;gt;&lt;br /&gt;
&amp;lt;includeonly&amp;gt;{{#ifeq:{{SUBPAGENAME}}|sandbox | |&lt;br /&gt;
[[Category:Error-handling modules]]&lt;br /&gt;
}}&amp;lt;/includeonly&amp;gt;&lt;/div&gt;</summary>
		<author><name>Taurussmith</name></author>
	</entry>
</feed>