{
  "source": "doc/api/errors.markdown",
  "classes": [
    {
      "textRaw": "Class: Error",
      "type": "class",
      "name": "Error",
      "desc": "<p>A generic JavaScript <code>Error</code> object that does not denote any specific\ncircumstance of why the error occurred. <code>Error</code> objects capture a &quot;stack trace&quot;\ndetailing the point in the code at which the <code>Error</code> was instantiated, and may\nprovide a text description of the error.\n\n</p>\n<p>All errors generated by Node.js, including all System and JavaScript errors,\nwill either be instances of, or inherit from, the <code>Error</code> class.\n\n</p>\n",
      "methods": [
        {
          "textRaw": "Error.captureStackTrace(targetObject[, constructorOpt])",
          "type": "method",
          "name": "captureStackTrace",
          "desc": "<p>Creates a <code>.stack</code> property on <code>targetObject</code>, which when accessed returns\na string representing the location in the code at which\n<code>Error.captureStackTrace()</code> was called.\n\n</p>\n<pre><code>const myObject = {};\nError.captureStackTrace(myObject);\nmyObject.stack  // similar to `new Error().stack`</code></pre>\n<p>The first line of the trace, instead of being prefixed with <code>ErrorType:\nmessage</code>, will be the result of calling <code>targetObject.toString()</code>.\n\n</p>\n<p>The optional <code>constructorOpt</code> argument accepts a function. If given, all frames\nabove <code>constructorOpt</code>, including <code>constructorOpt</code>, will be omitted from the\ngenerated stack trace.\n\n</p>\n<p>The <code>constructorOpt</code> argument is useful for hiding implementation\ndetails of error generation from an end user. For instance:\n\n</p>\n<pre><code>function MyError() {\n  Error.captureStackTrace(this, MyError);\n}\n\n// Without passing MyError to captureStackTrace, the MyError\n// frame would should up in the .stack property. by passing\n// the constructor, we omit that frame and all frames above it.\nnew MyError().stack</code></pre>\n",
          "signatures": [
            {
              "params": [
                {
                  "name": "targetObject"
                },
                {
                  "name": "constructorOpt",
                  "optional": true
                }
              ]
            }
          ]
        }
      ],
      "properties": [
        {
          "textRaw": "Error.stackTraceLimit",
          "name": "stackTraceLimit",
          "desc": "<p>The <code>Error.stackTraceLimit</code> property specifies the number of stack frames\ncollected by a stack trace (whether generated by <code>new Error().stack</code> or\n<code>Error.captureStackTrace(obj)</code>).\n\n</p>\n<p>The default value is <code>10</code> but may be set to any valid JavaScript number. Changes\nwill affect any stack trace captured <em>after</em> the value has been changed.\n\n</p>\n<p>If set to a non-number value, or set to a negative number, stack traces will\nnot capture any frames.\n\n</p>\n",
          "properties": [
            {
              "textRaw": "error.message",
              "name": "message",
              "desc": "<p>Returns the string description of error as set by calling <code>new Error(message)</code>.\nThe <code>message</code> passed to the constructor will also appear in the first line of\nthe stack trace of the <code>Error</code>, however changing this property after the\n<code>Error</code> object is created <em>may not</em> change the first line of the stack trace.\n\n</p>\n<pre><code>const err = new Error(&#39;The message&#39;);\nconsole.log(err.message);\n  // Prints: The message</code></pre>\n"
            },
            {
              "textRaw": "error.stack",
              "name": "stack",
              "desc": "<p>Returns a string describing the point in the code at which the <code>Error</code> was\ninstantiated.\n\n</p>\n<p>For example:\n\n</p>\n<pre><code>Error: Things keep happening!\n   at /home/gbusey/file.js:525:2\n   at Frobnicator.refrobulate (/home/gbusey/business-logic.js:424:21)\n   at Actor.&lt;anonymous&gt; (/home/gbusey/actors.js:400:8)\n   at increaseSynergy (/home/gbusey/actors.js:701:6)</code></pre>\n<p>The first line is formatted as <code>&lt;error class name&gt;: &lt;error message&gt;</code>, and\nis followed by a series of stack frames (each line beginning with &quot;at &quot;).\nEach frame describes a call site within the code that lead to the error being\ngenerated. V8 attempts to display a name for each function (by variable name,\nfunction name, or object method name), but occasionally it will not be able to\nfind a suitable name. If V8 cannot determine a name for the function, only\nlocation information will be displayed for that frame. Otherwise, the\ndetermined function name will be displayed with location information appended\nin parentheses.\n\n</p>\n<p>It is important to note that frames are <strong>only</strong> generated for JavaScript\nfunctions. If, for example, execution synchronously passes through a C++ addon\nfunction called <code>cheetahify</code>, which itself calls a JavaScript function, the\nframe representing the <code>cheetahify</code> call will <strong>not</strong> be present in the stack\ntraces:\n\n</p>\n<pre><code>const cheetahify = require(&#39;./native-binding.node&#39;);\n\nfunction makeFaster() {\n  // cheetahify *synchronously* calls speedy.\n  cheetahify(function speedy() {\n    throw new Error(&#39;oh no!&#39;);\n  });\n}\n\nmakeFaster(); // will throw:\n  // /home/gbusey/file.js:6\n  //     throw new Error(&#39;oh no!&#39;);\n  //           ^\n  // Error: oh no!\n  //     at speedy (/home/gbusey/file.js:6:11)\n  //     at makeFaster (/home/gbusey/file.js:5:3)\n  //     at Object.&lt;anonymous&gt; (/home/gbusey/file.js:10:1)\n  //     at Module._compile (module.js:456:26)\n  //     at Object.Module._extensions..js (module.js:474:10)\n  //     at Module.load (module.js:356:32)\n  //     at Function.Module._load (module.js:312:12)\n  //     at Function.Module.runMain (module.js:497:10)\n  //     at startup (node.js:119:16)\n  //     at node.js:906:3</code></pre>\n<p>The location information will be one of:\n\n</p>\n<ul>\n<li><code>native</code>, if the frame represents a call internal to V8 (as in <code>[].forEach</code>).</li>\n<li><code>plain-filename.js:line:column</code>, if the frame represents a call internal\n to Node.js.</li>\n<li><code>/absolute/path/to/file.js:line:column</code>, if the frame represents a call in\na user program, or its dependencies.</li>\n</ul>\n<p>The string representing the stack trace is lazily generated when the\n<code>error.stack</code> property is <strong>accessed</strong>.\n\n</p>\n<p>The number of frames captured by the stack trace is bounded by the smaller of\n<code>Error.stackTraceLimit</code> or the number of available frames on the current event\nloop tick.\n\n</p>\n<p>System-level errors are generated as augmented <code>Error</code> instances, which are\ndetailed <a href=\"#errors_system_errors\">below</a>.\n\n</p>\n"
            }
          ]
        }
      ],
      "signatures": [
        {
          "params": [
            {
              "name": "message"
            }
          ],
          "desc": "<p>Creates a new <code>Error</code> object and sets the <code>error.message</code> property to the\nprovided text message. If an object is passed as <code>message</code>, the text message\nis generated by calling <code>message.toString()</code>. The <code>error.stack</code> property will\nrepresent the point in the code at which <code>new Error()</code> was called. Stack traces\nare dependent on [V8&#39;s stack trace API][]. Stack traces extend only to either\n(a) the beginning of  <em>synchronous code execution</em>, or (b) the number of frames\ngiven by the property <code>Error.stackTraceLimit</code>, whichever is smaller.\n\n</p>\n"
        }
      ]
    },
    {
      "textRaw": "Class: RangeError",
      "type": "class",
      "name": "RangeError",
      "desc": "<p>A subclass of <code>Error</code> that indicates that a provided argument was not within the\nset or range of acceptable values for a function; whether that is a numeric\nrange, or outside the set of options for a given function parameter.\n\n</p>\n<p>For example:\n\n</p>\n<pre><code>require(&#39;net&#39;).connect(-1);\n  // throws RangeError, port should be &gt; 0 &amp;&amp; &lt; 65536</code></pre>\n<p>Node.js will generate and throw <code>RangeError</code> instances <em>immediately</em> as a form\nof argument validation.\n\n</p>\n"
    },
    {
      "textRaw": "Class: ReferenceError",
      "type": "class",
      "name": "ReferenceError",
      "desc": "<p>A subclass of <code>Error</code> that indicates that an attempt is being made to access a\nvariable that is not defined. Such errors commonly indicate typos in code, or\nan otherwise broken program.\n\n</p>\n<p>While client code may generate and propagate these errors, in practice, only V8\nwill do so.\n\n</p>\n<pre><code>doesNotExist;\n  // throws ReferenceError, doesNotExist is not a variable in this program.</code></pre>\n<p><code>ReferenceError</code> instances will have an <code>error.arguments</code> property whose value\nis an array containing a single element: a string representing the variable\nthat was not defined.\n\n</p>\n<pre><code>const assert = require(&#39;assert&#39;);\ntry {\n  doesNotExist;\n} catch(err) {\n  assert(err.arguments[0], &#39;doesNotExist&#39;);\n}</code></pre>\n<p>Unless an application is dynamically generating and running code,\n<code>ReferenceError</code> instances should always be considered a bug in the code\nor its dependencies.\n\n</p>\n"
    },
    {
      "textRaw": "Class: SyntaxError",
      "type": "class",
      "name": "SyntaxError",
      "desc": "<p>A subclass of <code>Error</code> that indicates that a program is not valid JavaScript.\nThese errors may only be generated and propagated as a result of code\nevaluation. Code evaluation may happen as a result of <code>eval</code>, <code>Function</code>,\n<code>require</code>, or [vm][]. These errors are almost always indicative of a broken\nprogram.\n\n</p>\n<pre><code>try {\n  require(&#39;vm&#39;).runInThisContext(&#39;binary ! isNotOk&#39;);\n} catch(err) {\n  // err will be a SyntaxError\n}</code></pre>\n<p><code>SyntaxError</code> instances are unrecoverable in the context that created them –\nthey may only be caught by other contexts.\n\n</p>\n"
    },
    {
      "textRaw": "Class: TypeError",
      "type": "class",
      "name": "TypeError",
      "desc": "<p>A subclass of <code>Error</code> that indicates that a provided argument is not an\nallowable type. For example, passing a function to a parameter which expects a\nstring would be considered a TypeError.\n\n</p>\n<pre><code>require(&#39;url&#39;).parse(function() { });\n  // throws TypeError, since it expected a string</code></pre>\n<p>Node.js will generate and throw <code>TypeError</code> instances <em>immediately</em> as a form\nof argument validation.\n\n</p>\n"
    }
  ],
  "miscs": [
    {
      "textRaw": "Errors",
      "name": "Errors",
      "type": "misc",
      "desc": "<p>Applications running in Node.js will generally experience four categories of\nerrors:\n\n</p>\n<ul>\n<li>Standard JavaScript errors such as:<ul>\n<li>[<code>EvalError</code>][]: thrown when a call to <code>eval()</code> fails.</li>\n<li>[<code>SyntaxError</code>][]: thrown in response to improper JavaScript language\nsyntax.</li>\n<li>[<code>RangeError</code>][]: thrown when a value is not within an expected range</li>\n<li>[<code>ReferenceError</code>][]: thrown when using undefined variables</li>\n<li>[<code>TypeError</code>][]: thrown when passing arguments of the wrong type</li>\n<li>[<code>URIError</code>][]: thrown when a global URI handling function is misused.</li>\n</ul>\n</li>\n<li>System errors triggered by underlying operating system constraints such\nas attempting to open a file that does not exist, attempting to send data\nover a closed socket, etc;</li>\n<li>And User-specified errors triggered by application code.</li>\n<li>Assertion Errors are a special class of error that can be triggered whenever\nNode.js detects an exceptional logic violation that should never occur. These\nare raised typically by the <code>assert</code> module.</li>\n</ul>\n<p>All JavaScript and System errors raised by Node.js inherit from, or are\ninstances of, the standard JavaScript [<code>Error</code>][] class and are guaranteed\nto provide <em>at least</em> the properties available on that class.\n\n</p>\n",
      "miscs": [
        {
          "textRaw": "Error Propagation and Interception",
          "name": "Error Propagation and Interception",
          "type": "misc",
          "desc": "<p>Node.js supports several mechanisms for propagating and handling errors that\noccur while an application is running. How these errors are reported and\nhandled depends entirely on the type of Error and the style of the API that is\ncalled.\n\n</p>\n<p>All JavaScript errors are handled as exceptions that <em>immediately</em> generate\nand throw an error using the standard JavaScript <code>throw</code> mechanism. These\nare handled using the [<code>try / catch</code> construct][] provided by the JavaScript\nlanguage.\n\n</p>\n<pre><code>// Throws with a ReferenceError because z is undefined\ntry {\n  const m = 1;\n  const n = m + z;\n} catch (err) {\n  // Handle the error here.\n}</code></pre>\n<p>Any use of the JavaScript <code>throw</code> mechanism will raise an exception that\n<em>must</em> be handled using <code>try / catch</code> or the Node.js process will exit\nimmediately.\n\n</p>\n<p>With few exceptions, <em>Synchronous</em> APIs (any blocking method that does not\naccept a <code>callback</code> function, such as [<code>fs.readFileSync</code>][]), will use <code>throw</code>\nto report errors.\n\n</p>\n<p>Errors that occur within <em>Asynchronous APIs</em> may be reported in multiple ways:\n\n</p>\n<ul>\n<li><p>Most asynchronous methods that accept a <code>callback</code> function will accept an\n<code>Error</code> object passed as the first argument to that function. If that first\nargument is not <code>null</code> and is an instance of <code>Error</code>, then an error occurred\nthat should be handled.</p>\n<pre><code>const fs = require(&#39;fs&#39;);\nfs.readFile(&#39;a file that does not exist&#39;, (err, data) =&gt; {\n  if (err) {\n    console.error(&#39;There was an error reading the file!&#39;, err);\n    return;\n  }\n  // Otherwise handle the data\n});</code></pre>\n</li>\n<li><p>When an asynchronous method is called on an object that is an <code>EventEmitter</code>,\nerrors can be routed to that object&#39;s <code>&#39;error&#39;</code> event.</p>\n<pre><code>const net = require(&#39;net&#39;);\nconst connection = net.connect(&#39;localhost&#39;);\n\n// Adding an &#39;error&#39; event handler to a stream:\nconnection.on(&#39;error&#39;, (err) =&gt; {\n  // If the connection is reset by the server, or if it can&#39;t\n  // connect at all, or on any sort of error encountered by\n  // the connection, the error will be sent here.\n  console.error(err);\n});\n\nconnection.pipe(process.stdout);</code></pre>\n</li>\n<li><p>A handful of typically asynchronous methods in the Node.js API may still\nuse the <code>throw</code> mechanism to raise exceptions that must be handled using\n<code>try / catch</code>. There is no comprehensive list of such methods; please\nrefer to the documentation of each method to determine the appropriate\nerror handling mechanism required.</p>\n</li>\n</ul>\n<p>The use of the <code>&#39;error&#39;</code> event mechanism is most common for [stream-based][]\nand [event emitter-based][] APIs, which themselves represent a series of\nasynchronous operations over time (as opposed to a single operation that may\npass or fail).\n\n</p>\n<p>For <em>all</em> <code>EventEmitter</code> objects, if an <code>&#39;error&#39;</code> event handler is not\nprovided, the error will be thrown, causing the Node.js process to report an\nunhandled exception and  crash unless either: The [<code>domain</code>][] module is used\nappropriately or a handler has been registered for the\n[<code>process.on(&#39;uncaughtException&#39;)</code>][] event.\n\n</p>\n<pre><code>const EventEmitter = require(&#39;events&#39;);\nconst ee = new EventEmitter();\n\nsetImmediate(() =&gt; {\n  // This will crash the process because no &#39;error&#39; event\n  // handler has been added.\n  ee.emit(&#39;error&#39;, new Error(&#39;This will crash&#39;));\n});</code></pre>\n<p>Errors generated in this way <em>cannot</em> be intercepted using <code>try / catch</code> as\nthey are thrown <em>after</em> the calling code has already exited.\n\n</p>\n<p>Developers must refer to the documentation for each method to determine\nexactly how errors raised by those methods are propagated.\n\n</p>\n",
          "miscs": [
            {
              "textRaw": "Node.js style callbacks",
              "name": "Node.js style callbacks",
              "type": "misc",
              "desc": "<p>Most asynchronous methods exposed by the Node.js core API follow an idiomatic\npattern  referred to as a &quot;Node.js style callback&quot;. With this pattern, a\ncallback function is passed to the method as an argument. When the operation\neither completes or an error is raised, the callback function is called with\nthe Error object (if any) passed as the first argument. If no error was raised,\nthe first argument will be passed as <code>null</code>.\n\n</p>\n<pre><code>const fs = require(&#39;fs&#39;);\n\nfunction nodeStyleCallback(err, data) {\n if (err) {\n   console.error(&#39;There was an error&#39;, err);\n   return;\n }\n console.log(data);\n}\n\nfs.readFile(&#39;/some/file/that/does-not-exist&#39;, nodeStyleCallback);\nfs.readFile(&#39;/some/file/that/does-exist&#39;, nodeStyleCallback)</code></pre>\n<p>The JavaScript <code>try / catch</code> mechanism <strong>cannot</strong> be used to intercept errors\ngenerated by asynchronous APIs.  A common mistake for beginners is to try to\nuse <code>throw</code> inside a Node.js style callback:\n\n</p>\n<pre><code>// THIS WILL NOT WORK:\nconst fs = require(&#39;fs&#39;);\n\ntry {\n  fs.readFile(&#39;/some/file/that/does-not-exist&#39;, (err, data) =&gt; {\n    // mistaken assumption: throwing here...\n    if (err) {\n      throw err;\n    }\n  });\n} catch(err) {\n  // This will not catch the throw!\n  console.log(err);\n}</code></pre>\n<p>This will not work because the callback function passed to <code>fs.readFile()</code> is\ncalled asynchronously. By the time the callback has been called, the\nsurrounding code (including the <code>try { } catch(err) { }</code> block will have\nalready exited. Throwing an error inside the callback <strong>can crash the Node.js\nprocess</strong> in most cases. If [domains][] are enabled, or a handler has been\nregistered with <code>process.on(&#39;uncaughtException&#39;)</code>, such errors can be\nintercepted.\n\n</p>\n"
            }
          ]
        },
        {
          "textRaw": "Exceptions vs. Errors",
          "name": "Exceptions vs. Errors",
          "type": "misc",
          "desc": "<p>A JavaScript exception is a value that is thrown as a result of an invalid\noperation or as the target of a <code>throw</code> statement. While it is not required\nthat these values are instances of <code>Error</code> or classes which inherit from\n<code>Error</code>, all exceptions thrown by Node.js or the JavaScript runtime <em>will</em> be\ninstances of Error.\n\n</p>\n<p>Some exceptions are <em>unrecoverable</em> at the JavaScript layer. Such exceptions\nwill <em>always</em> cause the Node.js process to crash. Examples include <code>assert()</code>\nchecks or <code>abort()</code> calls in the C++ layer.\n\n</p>\n"
        },
        {
          "textRaw": "System Errors",
          "name": "system_errors",
          "desc": "<p>System errors are generated when exceptions occur within the program&#39;s\nruntime environment. Typically, these are operational errors that occur\nwhen an application violates an operating system constraint such as attempting\nto read a file that does not exist or when the user does not have sufficient\npermissions.\n\n</p>\n<p>System errors are typically generated at the syscall level: an exhaustive list\nof error codes and their meanings is available by running <code>man 2 intro</code> or\n<code>man 3 errno</code> on most Unices; or [online][].\n\n</p>\n<p>In Node.js, system errors are represented as augmented <code>Error</code> objects with\nadded properties.\n\n</p>\n",
          "classes": [
            {
              "textRaw": "Class: System Error",
              "type": "class",
              "name": "System",
              "properties": [
                {
                  "textRaw": "error.code",
                  "name": "code",
                  "desc": "<p>Returns a string representing the error code, which is always <code>E</code> followed by\na sequence of capital letters, and may be referenced in <code>man 2 intro</code>.\n\n</p>\n<p>The properties <code>error.code</code> and <code>error.errno</code> are aliases of one another and\nreturn the same value.\n\n</p>\n"
                },
                {
                  "textRaw": "error.errno",
                  "name": "errno",
                  "desc": "<p>Returns a string representing the error code, which is always <code>E</code> followed by\na sequence of capital letters, and may be referenced in <code>man 2 intro</code>.\n\n</p>\n<p>The properties <code>error.code</code> and <code>error.errno</code> are aliases of one another and\nreturn the same value.\n\n</p>\n"
                },
                {
                  "textRaw": "error.syscall",
                  "name": "syscall",
                  "desc": "<p>Returns a string describing the [syscall][] that failed.\n\n</p>\n"
                }
              ]
            }
          ],
          "modules": [
            {
              "textRaw": "Common System Errors",
              "name": "common_system_errors",
              "desc": "<p>This list is <strong>not exhaustive</strong>, but enumerates many of the common system\nerrors encountered when writing a Node.js program. An exhaustive list may be\nfound [here][online].\n\n</p>\n<ul>\n<li><p><code>EACCES</code> (Permission denied): An attempt was made to access a file in a way\nforbidden by its file access permissions.</p>\n</li>\n<li><p><code>EADDRINUSE</code> (Address already in use):  An attempt to bind a server\n([<code>net</code>][], [<code>http</code>][], or [<code>https</code>][]) to a local address failed due to\nanother server on the local system already occupying that address.</p>\n</li>\n<li><p><code>ECONNREFUSED</code> (Connection refused): No connection could be made because the\ntarget machine actively refused it. This usually results from trying to\nconnect to a service that is inactive on the foreign host.</p>\n</li>\n<li><p><code>ECONNRESET</code> (Connection reset by peer): A connection was forcibly closed by\na peer. This normally results from a loss of the connection on the remote\nsocket due to a timeout or reboot. Commonly encountered via the [<code>http</code>][]\nand [<code>net</code>][] modules.</p>\n</li>\n<li><p><code>EEXIST</code> (File exists): An existing file was the target of an operation that\nrequired that the target not exist.</p>\n</li>\n<li><p><code>EISDIR</code> (Is a directory): An operation expected a file, but the given\npathname was a directory.</p>\n</li>\n<li><p><code>EMFILE</code> (Too many open files in system): Maximum number of\n[file descriptors][] allowable on the system has been reached, and\nrequests for another descriptor cannot be fulfilled until at least one\nhas been closed. This is encountered when opening many files at once in\nparallel, especially on systems (in particular, OS X) where there is a low\nfile descriptor limit for processes. To remedy a low limit, run\n<code>ulimit -n 2048</code> in the same shell that will run the Node.js process.</p>\n</li>\n<li><p><code>ENOENT</code> (No such file or directory): Commonly raised by [<code>fs</code>][] operations\nto indicate that a component of the specified pathname does not exist -- no\nentity (file or directory) could be found by the given path.</p>\n</li>\n<li><p><code>ENOTDIR</code> (Not a directory): A component of the given pathname existed, but\nwas not a directory as expected. Commonly raised by [<code>fs.readdir</code>][].</p>\n</li>\n<li><p><code>ENOTEMPTY</code> (Directory not empty): A directory with entries was the target\nof an operation that requires an empty directory -- usually [<code>fs.unlink</code>][].</p>\n</li>\n<li><p><code>EPERM</code> (Operation not permitted): An attempt was made to perform an\noperation that requires elevated privileges.</p>\n</li>\n<li><p><code>EPIPE</code> (Broken pipe): A write on a pipe, socket, or FIFO for which there is\nno process to read the data. Commonly encountered at the [<code>net</code>][] and\n[<code>http</code>][] layers, indicative that the remote side of the stream being\nwritten to has been closed.</p>\n</li>\n<li><p><code>ETIMEDOUT</code> (Operation timed out): A connect or send request failed because\nthe connected party did not properly respond after a period of time. Usually\nencountered by [<code>http</code>][] or [<code>net</code>][] -- often a sign that a <code>socket.end()</code>\nwas not properly called.</p>\n</li>\n</ul>\n",
              "type": "module",
              "displayName": "Common System Errors"
            }
          ],
          "type": "misc",
          "displayName": "System Errors"
        }
      ],
      "classes": [
        {
          "textRaw": "Class: Error",
          "type": "class",
          "name": "Error",
          "desc": "<p>A generic JavaScript <code>Error</code> object that does not denote any specific\ncircumstance of why the error occurred. <code>Error</code> objects capture a &quot;stack trace&quot;\ndetailing the point in the code at which the <code>Error</code> was instantiated, and may\nprovide a text description of the error.\n\n</p>\n<p>All errors generated by Node.js, including all System and JavaScript errors,\nwill either be instances of, or inherit from, the <code>Error</code> class.\n\n</p>\n",
          "methods": [
            {
              "textRaw": "Error.captureStackTrace(targetObject[, constructorOpt])",
              "type": "method",
              "name": "captureStackTrace",
              "desc": "<p>Creates a <code>.stack</code> property on <code>targetObject</code>, which when accessed returns\na string representing the location in the code at which\n<code>Error.captureStackTrace()</code> was called.\n\n</p>\n<pre><code>const myObject = {};\nError.captureStackTrace(myObject);\nmyObject.stack  // similar to `new Error().stack`</code></pre>\n<p>The first line of the trace, instead of being prefixed with <code>ErrorType:\nmessage</code>, will be the result of calling <code>targetObject.toString()</code>.\n\n</p>\n<p>The optional <code>constructorOpt</code> argument accepts a function. If given, all frames\nabove <code>constructorOpt</code>, including <code>constructorOpt</code>, will be omitted from the\ngenerated stack trace.\n\n</p>\n<p>The <code>constructorOpt</code> argument is useful for hiding implementation\ndetails of error generation from an end user. For instance:\n\n</p>\n<pre><code>function MyError() {\n  Error.captureStackTrace(this, MyError);\n}\n\n// Without passing MyError to captureStackTrace, the MyError\n// frame would should up in the .stack property. by passing\n// the constructor, we omit that frame and all frames above it.\nnew MyError().stack</code></pre>\n",
              "signatures": [
                {
                  "params": [
                    {
                      "name": "targetObject"
                    },
                    {
                      "name": "constructorOpt",
                      "optional": true
                    }
                  ]
                }
              ]
            }
          ],
          "properties": [
            {
              "textRaw": "Error.stackTraceLimit",
              "name": "stackTraceLimit",
              "desc": "<p>The <code>Error.stackTraceLimit</code> property specifies the number of stack frames\ncollected by a stack trace (whether generated by <code>new Error().stack</code> or\n<code>Error.captureStackTrace(obj)</code>).\n\n</p>\n<p>The default value is <code>10</code> but may be set to any valid JavaScript number. Changes\nwill affect any stack trace captured <em>after</em> the value has been changed.\n\n</p>\n<p>If set to a non-number value, or set to a negative number, stack traces will\nnot capture any frames.\n\n</p>\n",
              "properties": [
                {
                  "textRaw": "error.message",
                  "name": "message",
                  "desc": "<p>Returns the string description of error as set by calling <code>new Error(message)</code>.\nThe <code>message</code> passed to the constructor will also appear in the first line of\nthe stack trace of the <code>Error</code>, however changing this property after the\n<code>Error</code> object is created <em>may not</em> change the first line of the stack trace.\n\n</p>\n<pre><code>const err = new Error(&#39;The message&#39;);\nconsole.log(err.message);\n  // Prints: The message</code></pre>\n"
                },
                {
                  "textRaw": "error.stack",
                  "name": "stack",
                  "desc": "<p>Returns a string describing the point in the code at which the <code>Error</code> was\ninstantiated.\n\n</p>\n<p>For example:\n\n</p>\n<pre><code>Error: Things keep happening!\n   at /home/gbusey/file.js:525:2\n   at Frobnicator.refrobulate (/home/gbusey/business-logic.js:424:21)\n   at Actor.&lt;anonymous&gt; (/home/gbusey/actors.js:400:8)\n   at increaseSynergy (/home/gbusey/actors.js:701:6)</code></pre>\n<p>The first line is formatted as <code>&lt;error class name&gt;: &lt;error message&gt;</code>, and\nis followed by a series of stack frames (each line beginning with &quot;at &quot;).\nEach frame describes a call site within the code that lead to the error being\ngenerated. V8 attempts to display a name for each function (by variable name,\nfunction name, or object method name), but occasionally it will not be able to\nfind a suitable name. If V8 cannot determine a name for the function, only\nlocation information will be displayed for that frame. Otherwise, the\ndetermined function name will be displayed with location information appended\nin parentheses.\n\n</p>\n<p>It is important to note that frames are <strong>only</strong> generated for JavaScript\nfunctions. If, for example, execution synchronously passes through a C++ addon\nfunction called <code>cheetahify</code>, which itself calls a JavaScript function, the\nframe representing the <code>cheetahify</code> call will <strong>not</strong> be present in the stack\ntraces:\n\n</p>\n<pre><code>const cheetahify = require(&#39;./native-binding.node&#39;);\n\nfunction makeFaster() {\n  // cheetahify *synchronously* calls speedy.\n  cheetahify(function speedy() {\n    throw new Error(&#39;oh no!&#39;);\n  });\n}\n\nmakeFaster(); // will throw:\n  // /home/gbusey/file.js:6\n  //     throw new Error(&#39;oh no!&#39;);\n  //           ^\n  // Error: oh no!\n  //     at speedy (/home/gbusey/file.js:6:11)\n  //     at makeFaster (/home/gbusey/file.js:5:3)\n  //     at Object.&lt;anonymous&gt; (/home/gbusey/file.js:10:1)\n  //     at Module._compile (module.js:456:26)\n  //     at Object.Module._extensions..js (module.js:474:10)\n  //     at Module.load (module.js:356:32)\n  //     at Function.Module._load (module.js:312:12)\n  //     at Function.Module.runMain (module.js:497:10)\n  //     at startup (node.js:119:16)\n  //     at node.js:906:3</code></pre>\n<p>The location information will be one of:\n\n</p>\n<ul>\n<li><code>native</code>, if the frame represents a call internal to V8 (as in <code>[].forEach</code>).</li>\n<li><code>plain-filename.js:line:column</code>, if the frame represents a call internal\n to Node.js.</li>\n<li><code>/absolute/path/to/file.js:line:column</code>, if the frame represents a call in\na user program, or its dependencies.</li>\n</ul>\n<p>The string representing the stack trace is lazily generated when the\n<code>error.stack</code> property is <strong>accessed</strong>.\n\n</p>\n<p>The number of frames captured by the stack trace is bounded by the smaller of\n<code>Error.stackTraceLimit</code> or the number of available frames on the current event\nloop tick.\n\n</p>\n<p>System-level errors are generated as augmented <code>Error</code> instances, which are\ndetailed <a href=\"#errors_system_errors\">below</a>.\n\n</p>\n"
                }
              ]
            }
          ],
          "signatures": [
            {
              "params": [
                {
                  "name": "message"
                }
              ],
              "desc": "<p>Creates a new <code>Error</code> object and sets the <code>error.message</code> property to the\nprovided text message. If an object is passed as <code>message</code>, the text message\nis generated by calling <code>message.toString()</code>. The <code>error.stack</code> property will\nrepresent the point in the code at which <code>new Error()</code> was called. Stack traces\nare dependent on [V8&#39;s stack trace API][]. Stack traces extend only to either\n(a) the beginning of  <em>synchronous code execution</em>, or (b) the number of frames\ngiven by the property <code>Error.stackTraceLimit</code>, whichever is smaller.\n\n</p>\n"
            }
          ]
        },
        {
          "textRaw": "Class: RangeError",
          "type": "class",
          "name": "RangeError",
          "desc": "<p>A subclass of <code>Error</code> that indicates that a provided argument was not within the\nset or range of acceptable values for a function; whether that is a numeric\nrange, or outside the set of options for a given function parameter.\n\n</p>\n<p>For example:\n\n</p>\n<pre><code>require(&#39;net&#39;).connect(-1);\n  // throws RangeError, port should be &gt; 0 &amp;&amp; &lt; 65536</code></pre>\n<p>Node.js will generate and throw <code>RangeError</code> instances <em>immediately</em> as a form\nof argument validation.\n\n</p>\n"
        },
        {
          "textRaw": "Class: ReferenceError",
          "type": "class",
          "name": "ReferenceError",
          "desc": "<p>A subclass of <code>Error</code> that indicates that an attempt is being made to access a\nvariable that is not defined. Such errors commonly indicate typos in code, or\nan otherwise broken program.\n\n</p>\n<p>While client code may generate and propagate these errors, in practice, only V8\nwill do so.\n\n</p>\n<pre><code>doesNotExist;\n  // throws ReferenceError, doesNotExist is not a variable in this program.</code></pre>\n<p><code>ReferenceError</code> instances will have an <code>error.arguments</code> property whose value\nis an array containing a single element: a string representing the variable\nthat was not defined.\n\n</p>\n<pre><code>const assert = require(&#39;assert&#39;);\ntry {\n  doesNotExist;\n} catch(err) {\n  assert(err.arguments[0], &#39;doesNotExist&#39;);\n}</code></pre>\n<p>Unless an application is dynamically generating and running code,\n<code>ReferenceError</code> instances should always be considered a bug in the code\nor its dependencies.\n\n</p>\n"
        },
        {
          "textRaw": "Class: SyntaxError",
          "type": "class",
          "name": "SyntaxError",
          "desc": "<p>A subclass of <code>Error</code> that indicates that a program is not valid JavaScript.\nThese errors may only be generated and propagated as a result of code\nevaluation. Code evaluation may happen as a result of <code>eval</code>, <code>Function</code>,\n<code>require</code>, or [vm][]. These errors are almost always indicative of a broken\nprogram.\n\n</p>\n<pre><code>try {\n  require(&#39;vm&#39;).runInThisContext(&#39;binary ! isNotOk&#39;);\n} catch(err) {\n  // err will be a SyntaxError\n}</code></pre>\n<p><code>SyntaxError</code> instances are unrecoverable in the context that created them –\nthey may only be caught by other contexts.\n\n</p>\n"
        },
        {
          "textRaw": "Class: TypeError",
          "type": "class",
          "name": "TypeError",
          "desc": "<p>A subclass of <code>Error</code> that indicates that a provided argument is not an\nallowable type. For example, passing a function to a parameter which expects a\nstring would be considered a TypeError.\n\n</p>\n<pre><code>require(&#39;url&#39;).parse(function() { });\n  // throws TypeError, since it expected a string</code></pre>\n<p>Node.js will generate and throw <code>TypeError</code> instances <em>immediately</em> as a form\nof argument validation.\n\n</p>\n"
        }
      ]
    }
  ]
}
