module-barejs.Exception.html 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>JSDoc: Class: Exception</title>
  6. <script src="scripts/prettify/prettify.js"> </script>
  7. <script src="scripts/prettify/lang-css.js"> </script>
  8. <!--[if lt IE 9]>
  9. <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  10. <![endif]-->
  11. <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
  12. <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
  13. </head>
  14. <body>
  15. <div id="main">
  16. <h1 class="page-title">Class: Exception</h1>
  17. <section>
  18. <header>
  19. <h2><span class="attribs"><span class="type-signature"></span></span>
  20. <span class="ancestors"><a href="module-barejs.html">barejs</a>.</span>Exception<span class="signature">(_message, _creatorFn<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h2>
  21. <div class="class-description"><p>Exception creates a normalized base class for creating custom Error (Exception) classes to throw.
  22. It handles determining the stack trace for the created exception in a cross browser way.
  23. This class relies on the constructor property being set correctly, otherwise sub-class constructors
  24. may show up in the stack trace. Using decl.declareClass
  25. to define base classes ensures the constructor property is set correctly.</p>
  26. <p>Sub classes should also set the name property on the prototype to the name of the exception, for example:</p>
  27. <pre class="prettyprint source"><code> function MyCustomError( _message, _myAdditionalData )
  28. {
  29. Exception.call( this, _message );
  30. this.myAdditionalData = _myAdditionalData;
  31. }
  32. decl.declareClass( MyCustomError, Exception,
  33. {
  34. // Setting the name ensures our custom error looks and behaves as expected
  35. // Avoid using MyCustomError.name (named function name) as the name may get
  36. // mangled by a minifier/uglifier.
  37. name: &quot;MyCustomError&quot;,
  38. myAdditionalData: null
  39. } );</code></pre></div>
  40. </header>
  41. <article>
  42. <div class="container-overview">
  43. <h2>Constructor</h2>
  44. <h4 class="name" id="Exception"><span class="type-signature"></span>new Exception<span class="signature">(_message, _creatorFn<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
  45. <div class="description">
  46. <p>The Exception constructor will set up the exception with a name and stack property. You can pass the &quot;creator function&quot;
  47. as second argument, this is the topmost function that will be ignored from the stack. It defaults to the constructed
  48. object's constructor, which ensures the &quot;Exception&quot; and parent constructors never show up in the stack.</p>
  49. </div>
  50. <h5>Parameters:</h5>
  51. <table class="params">
  52. <thead>
  53. <tr>
  54. <th>Name</th>
  55. <th>Type</th>
  56. <th>Attributes</th>
  57. <th class="last">Description</th>
  58. </tr>
  59. </thead>
  60. <tbody>
  61. <tr>
  62. <td class="name"><code>_message</code></td>
  63. <td class="type">
  64. <span class="param-type">string</span>
  65. </td>
  66. <td class="attributes">
  67. </td>
  68. <td class="description last"><p>The message that describes the exception.</p></td>
  69. </tr>
  70. <tr>
  71. <td class="name"><code>_creatorFn</code></td>
  72. <td class="type">
  73. <span class="param-type">function</span>
  74. </td>
  75. <td class="attributes">
  76. &lt;optional><br>
  77. </td>
  78. <td class="description last"><p>Optional: function to exclude from the call stack.
  79. Defaults to the this.constructor function.</p></td>
  80. </tr>
  81. </tbody>
  82. </table>
  83. <dl class="details">
  84. <dt class="tag-source">Source:</dt>
  85. <dd class="tag-source"><ul class="dummy"><li>
  86. <a href="Exception.js.html">Exception.js</a>, <a href="Exception.js.html#line134">line 134</a>
  87. </li></ul></dd>
  88. </dl>
  89. </div>
  90. <h3 class="subsection-title">Members</h3>
  91. <h4 class="name" id="name"><span class="type-signature"></span>name<span class="type-signature"> :string</span></h4>
  92. <div class="description">
  93. <p>The name of the Exception type. Base classes are supposed to set the correct name on the prototype too.
  94. It is recommended not to use the constructor function's name for this, as that might get obfuscated by
  95. a minifier, or the name property may not be supported at all.</p>
  96. </div>
  97. <h5>Type:</h5>
  98. <ul>
  99. <li>
  100. <span class="param-type">string</span>
  101. </li>
  102. </ul>
  103. <dl class="details">
  104. <dt class="tag-source">Source:</dt>
  105. <dd class="tag-source"><ul class="dummy"><li>
  106. <a href="Exception.js.html">Exception.js</a>, <a href="Exception.js.html#line196">line 196</a>
  107. </li></ul></dd>
  108. </dl>
  109. </article>
  110. </section>
  111. </div>
  112. <nav>
  113. <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-barejs.html">barejs</a></li><li><a href="module-barejs_polyfill.html">barejs/polyfill</a></li><li><a href="module-barejs_polyfill_Intl.html">barejs/polyfill/Intl</a></li></ul><h3>Classes</h3><ul><li><a href="module-barejs.decl.html">decl</a></li><li><a href="module-barejs.decl-Enum.html">Enum</a></li><li><a href="module-barejs.decl-Interface.html">Interface</a></li><li><a href="module-barejs.decl-SpecialType.html">SpecialType</a></li><li><a href="module-barejs.Destroyable.html">Destroyable</a></li><li><a href="module-barejs.EventArgs.html">EventArgs</a></li><li><a href="module-barejs.Evented.html">Evented</a></li><li><a href="module-barejs.Evented-EventedHandle.html">EventedHandle</a></li><li><a href="module-barejs.Exception.html">Exception</a></li><li><a href="module-barejs_polyfill.Array.html">Array</a></li><li><a href="module-barejs_polyfill.Date.html">Date</a></li><li><a href="module-barejs_polyfill.EntryStore.html">EntryStore</a></li><li><a href="module-barejs_polyfill.EntryStore.Iterator.html">Iterator</a></li><li><a href="module-barejs_polyfill.Function.html">Function</a></li><li><a href="module-barejs_polyfill.Map.html">Map</a></li><li><a href="module-barejs_polyfill.Map-MapIterator.html">MapIterator</a></li><li><a href="module-barejs_polyfill.Math.html">Math</a></li><li><a href="module-barejs_polyfill.Number.html">Number</a></li><li><a href="module-barejs_polyfill.Object.html">Object</a></li><li><a href="module-barejs_polyfill.Promise.html">Promise</a></li><li><a href="module-barejs_polyfill.Set.html">Set</a></li><li><a href="module-barejs_polyfill.Set-SetIterator.html">SetIterator</a></li><li><a href="module-barejs_polyfill.String.html">String</a></li><li><a href="module-barejs_polyfill.Symbol.html">Symbol</a></li><li><a href="module-barejs_polyfill.WeakMap.html">WeakMap</a></li><li><a href="module-barejs_polyfill.WeakSet.html">WeakSet</a></li><li><a href="module-barejs_polyfill_Intl.DateTimeFormat.html">DateTimeFormat</a></li><li><a href="module-barejs_polyfill_Intl.DateTimeFormat-DateTimeFormatOptions.html">DateTimeFormatOptions</a></li><li><a href="module-barejs_polyfill_Intl.NumberFormat.html">NumberFormat</a></li><li><a href="module-barejs_polyfill_Intl.NumberFormat-NumberFormatOptions.html">NumberFormatOptions</a></li><li><a href="module-barejs_polyfill_Intl-Format.html">Format</a></li></ul>
  114. </nav>
  115. <br class="clear">
  116. <footer>
  117. Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed Oct 03 2018 15:59:34 GMT+0200 (W. Europe Daylight Time)
  118. </footer>
  119. <script> prettyPrint(); </script>
  120. <script src="scripts/linenumber.js"> </script>
  121. </body>
  122. </html>