Skip to content

Commit c4c6911

Browse files
committed
Merge pull request #9 from mathematicalcoffee/plugin-error-reporting
for #5 - mention jsdoc/util/error in plugin docs
2 parents 5ead48a + d731470 commit c4c6911

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

Jake/articles/about-plugins

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@
4848
</a></li>
4949
</ol>
5050
</li>
51+
<li><a href="#throwing-errors">Throwing Errors
52+
</a>
53+
</li>
5154
</ol>
5255
</li>
5356
<li><a href="#packaging-jsdoc-3-plugins">Packaging JSDoc 3 Plugins
@@ -537,6 +540,21 @@ function isInWidgetFactory(node, depth) {
537540
Lastly, the visitors are executed in the order the plugins are listed in the conf.json file. A plugin can stop later plugins from visiting a node by setting a <code>stopPropagation</code> property on the event object (e.stopPropagation = true). A plugin can stop the event from firing setting a <code>preventDefault</code> property.
538541
</p>
539542

543+
<h3 name="throwing-errors" id="throwing-errors">
544+
Throwing Errors
545+
</h3>
546+
<p>
547+
If you wish your plugin to throw an error, do it using the <code>handle</code> function in the <code>jsdoc/util/error</code> module.
548+
</p>
549+
550+
{{#example}}Example
551+
require('jsdoc/util/error').handle( new Error('I do not like green eggs and ham!') );
552+
{{/example}}
553+
554+
<p>
555+
By default this will throw the error, halting the execution of <code>jsdoc</code>. However, if the user used the <code>--lenient</code> switch when they ran <code>jsdoc</code> it will simply log the error to the console and continue.
556+
</p>
557+
540558
<h2 name="packaging-jsdoc-3-plugins" id="packaging-jsdoc-3-plugins">
541559
Packaging JSDoc 3 Plugins
542560
</h2>

about-plugins.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@ <h1>JSDoc 3 Plugin Reference</h1>
221221
</a></li>
222222
</ol>
223223
</li>
224+
<li><a href="#throwing-errors">Throwing Errors
225+
</a>
226+
</li>
224227
</ol>
225228
</li>
226229
<li><a href="#packaging-jsdoc-3-plugins">Packaging JSDoc 3 Plugins
@@ -755,6 +758,25 @@ <h4 name="example" id="example">
755758
Lastly, the visitors are executed in the order the plugins are listed in the conf.json file. A plugin can stop later plugins from visiting a node by setting a <code>stopPropagation</code> property on the event object (e.stopPropagation = true). A plugin can stop the event from firing setting a <code>preventDefault</code> property.
756759
</p>
757760

761+
<h3 name="throwing-errors" id="throwing-errors">
762+
Throwing Errors
763+
</h3>
764+
<p>
765+
If you wish your plugin to throw an error, do it using the <code>handle</code> function in the <code>jsdoc/util/error</code> module.
766+
</p>
767+
768+
<dl class="example">
769+
<dt>Example</dt>
770+
<dd>
771+
<pre class="prettyprint lang-js">
772+
require('jsdoc/util/error').handle( new Error('I do not like green eggs and ham!') );
773+
774+
</pre>
775+
</dd>
776+
</dl><p>
777+
By default this will throw the error, halting the execution of <code>jsdoc</code>. However, if the user used the <code>--lenient</code> switch when they ran <code>jsdoc</code> it will simply log the error to the console and continue.
778+
</p>
779+
758780
<h2 name="packaging-jsdoc-3-plugins" id="packaging-jsdoc-3-plugins">
759781
Packaging JSDoc 3 Plugins
760782
</h2>

0 commit comments

Comments
 (0)