<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.stiles.casa/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://wiki.stiles.casa/index.php?action=history&amp;feed=atom&amp;title=Module%3AProtect%2Fdoc"/>
	<link rel="alternate" type="text/html" href="https://wiki.stiles.casa/index.php?title=Module:Protect/doc&amp;action=history"/>
	<updated>2026-05-07T06:42:05Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.2</generator>
	<entry>
		<id>https://wiki.stiles.casa/index.php?title=Module:Protect/doc&amp;diff=5839&amp;oldid=prev</id>
		<title>Maxwells: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://wiki.stiles.casa/index.php?title=Module:Protect/doc&amp;diff=5839&amp;oldid=prev"/>
		<updated>2022-06-11T21:02:14Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 15:02, 11 June 2022&lt;/td&gt;
				&lt;/tr&gt;
&lt;!-- diff cache key wikidb:diff::1.12:old-5838:rev-5839 --&gt;
&lt;/table&gt;</summary>
		<author><name>Maxwells</name></author>
	</entry>
	<entry>
		<id>https://wiki.stiles.casa/index.php?title=Module:Protect/doc&amp;diff=5838&amp;oldid=prev</id>
		<title>en&gt;Pppery: Come on, a module usedo n 200,000 pages and in system messages is clearly not alpha</title>
		<link rel="alternate" type="text/html" href="https://wiki.stiles.casa/index.php?title=Module:Protect/doc&amp;diff=5838&amp;oldid=prev"/>
		<updated>2021-09-25T00:21:36Z</updated>

		<summary type="html">&lt;p&gt;Come on, a module usedo n 200,000 pages and in system messages is clearly not alpha&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;
&lt;br /&gt;
 local protect = require(&amp;#039;Module:Protect&amp;#039;)&lt;br /&gt;
 local protectedFunc = &amp;#039;&amp;#039;&amp;#039;protect(&amp;#039;&amp;#039;func&amp;#039;&amp;#039;, &amp;#039;&amp;#039;errFormat&amp;#039;&amp;#039;, &amp;#039;&amp;#039;options&amp;#039;&amp;#039;)&amp;#039;&amp;#039;&amp;#039;&lt;br /&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;
&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 = &amp;#039;&amp;#039;&amp;#039;protect&amp;#039;&amp;#039;&amp;#039;(p.main)&lt;br /&gt;
 &lt;br /&gt;
 return p&lt;br /&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>en&gt;Pppery</name></author>
	</entry>
</feed>