<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://pool.calebcooper.ie/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://pool.calebcooper.ie/index.php?action=history&amp;feed=atom&amp;title=Module%3AProtect%2Fdoc"/>
	<link rel="alternate" type="text/html" href="https://pool.calebcooper.ie/index.php?title=Module:Protect/doc&amp;action=history"/>
	<updated>2026-04-10T08:13:21Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://pool.calebcooper.ie/index.php?title=Module:Protect/doc&amp;diff=13530&amp;oldid=prev</id>
		<title>Caleb Cooper at 18:25, 21 October 2020</title>
		<link rel="alternate" type="text/html" href="https://pool.calebcooper.ie/index.php?title=Module:Protect/doc&amp;diff=13530&amp;oldid=prev"/>
		<updated>2020-10-21T18:25:09Z</updated>

		<summary type="html">&lt;p&gt;&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 18:25, 21 October 2020&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Module rating|a}}&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Module rating|a}}&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{used in system}}&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{used in system}}&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Help:Lua metamodules|&lt;/del&gt;metamodule&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;]]&lt;/del&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.&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;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.&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Commons Import}}&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Commons Import}}&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Usage ==&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Usage ==&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Caleb Cooper</name></author>
	</entry>
	<entry>
		<id>https://pool.calebcooper.ie/index.php?title=Module:Protect/doc&amp;diff=13529&amp;oldid=prev</id>
		<title>Caleb Cooper: Created page with &quot;{{Module rating|a}} {{used in system}} This metamodule simplifies error handling in other modules. It transforms a function, which may throw an error,...&quot;</title>
		<link rel="alternate" type="text/html" href="https://pool.calebcooper.ie/index.php?title=Module:Protect/doc&amp;diff=13529&amp;oldid=prev"/>
		<updated>2020-10-21T18:24:51Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{Module rating|a}} {{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,...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Module rating|a}}&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;
{{Commons Import}}&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;
[[Category:Lua metamodules]]&lt;br /&gt;
}}&amp;lt;/includeonly&amp;gt;&lt;/div&gt;</summary>
		<author><name>Caleb Cooper</name></author>
	</entry>
</feed>