{
  "type": "module",
  "source": "doc/api/api-errors.md",
  "modules": [
    {
      "textRaw": "Errors",
      "name": "errors",
      "type": "module",
      "desc": "<p>Undici exposes a variety of error objects that you can use to enhance your error handling.\nYou can find all the error objects inside the <code>errors</code> key.</p>\n<pre><code class=\"language-js\">import { errors } from 'undici'\n</code></pre>\n<table>\n<thead>\n<tr>\n<th>Error</th>\n<th>Error Codes</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>UndiciError</code></td>\n<td><code>UND_ERR</code></td>\n<td>all errors below are extended from <code>UndiciError</code>.</td>\n</tr>\n<tr>\n<td><code>ConnectTimeoutError</code></td>\n<td><code>UND_ERR_CONNECT_TIMEOUT</code></td>\n<td>socket is destroyed due to connect timeout.</td>\n</tr>\n<tr>\n<td><code>HeadersTimeoutError</code></td>\n<td><code>UND_ERR_HEADERS_TIMEOUT</code></td>\n<td>socket is destroyed due to headers timeout.</td>\n</tr>\n<tr>\n<td><code>HeadersOverflowError</code></td>\n<td><code>UND_ERR_HEADERS_OVERFLOW</code></td>\n<td>socket is destroyed due to headers' max size being exceeded.</td>\n</tr>\n<tr>\n<td><code>BodyTimeoutError</code></td>\n<td><code>UND_ERR_BODY_TIMEOUT</code></td>\n<td>socket is destroyed due to body timeout.</td>\n</tr>\n<tr>\n<td><code>InvalidArgumentError</code></td>\n<td><code>UND_ERR_INVALID_ARG</code></td>\n<td>passed an invalid argument.</td>\n</tr>\n<tr>\n<td><code>InvalidReturnValueError</code></td>\n<td><code>UND_ERR_INVALID_RETURN_VALUE</code></td>\n<td>returned an invalid value.</td>\n</tr>\n<tr>\n<td><code>RequestAbortedError</code></td>\n<td><code>UND_ERR_ABORTED</code></td>\n<td>the request has been aborted by the user</td>\n</tr>\n<tr>\n<td><code>ClientDestroyedError</code></td>\n<td><code>UND_ERR_DESTROYED</code></td>\n<td>trying to use a destroyed client.</td>\n</tr>\n<tr>\n<td><code>ClientClosedError</code></td>\n<td><code>UND_ERR_CLOSED</code></td>\n<td>trying to use a closed client.</td>\n</tr>\n<tr>\n<td><code>SocketError</code></td>\n<td><code>UND_ERR_SOCKET</code></td>\n<td>there is an error with the socket.</td>\n</tr>\n<tr>\n<td><code>NotSupportedError</code></td>\n<td><code>UND_ERR_NOT_SUPPORTED</code></td>\n<td>encountered unsupported functionality.</td>\n</tr>\n<tr>\n<td><code>RequestContentLengthMismatchError</code></td>\n<td><code>UND_ERR_REQ_CONTENT_LENGTH_MISMATCH</code></td>\n<td>request body does not match content-length header</td>\n</tr>\n<tr>\n<td><code>ResponseContentLengthMismatchError</code></td>\n<td><code>UND_ERR_RES_CONTENT_LENGTH_MISMATCH</code></td>\n<td>response body does not match content-length header</td>\n</tr>\n<tr>\n<td><code>InformationalError</code></td>\n<td><code>UND_ERR_INFO</code></td>\n<td>expected error with reason</td>\n</tr>\n<tr>\n<td><code>ResponseExceededMaxSizeError</code></td>\n<td><code>UND_ERR_RES_EXCEEDED_MAX_SIZE</code></td>\n<td>response body exceed the max size allowed</td>\n</tr>\n<tr>\n<td><code>SecureProxyConnectionError</code></td>\n<td><code>UND_ERR_PRX_TLS</code></td>\n<td>tls connection to a proxy failed</td>\n</tr>\n<tr>\n<td><code>MessageSizeExceededError</code></td>\n<td><code>UND_ERR_WS_MESSAGE_SIZE_EXCEEDED</code></td>\n<td>WebSocket decompressed message exceeded the maximum allowed size</td>\n</tr>\n<tr>\n<td><code>AbortError</code></td>\n<td><code>UND_ERR_ABORT</code></td>\n<td>the operation was aborted (base class of <code>RequestAbortedError</code>).</td>\n</tr>\n<tr>\n<td><code>RequestRetryError</code></td>\n<td><code>UND_ERR_REQ_RETRY</code></td>\n<td>request failed and could not be retried; carries <code>statusCode</code>, <code>headers</code> and <code>data</code>.</td>\n</tr>\n<tr>\n<td><code>ResponseError</code></td>\n<td><code>UND_ERR_RESPONSE</code></td>\n<td>response returned an error status code; carries <code>statusCode</code>, <code>headers</code> and <code>body</code>.</td>\n</tr>\n<tr>\n<td><code>MaxOriginsReachedError</code></td>\n<td><code>UND_ERR_MAX_ORIGINS_REACHED</code></td>\n<td>the maximum number of allowed origins has been reached.</td>\n</tr>\n<tr>\n<td><code>BalancedPoolMissingUpstreamError</code></td>\n<td><code>UND_ERR_BPL_MISSING_UPSTREAM</code></td>\n<td>no upstream has been added to the <code>BalancedPool</code>.</td>\n</tr>\n<tr>\n<td><code>Socks5ProxyError</code></td>\n<td><code>UND_ERR_SOCKS5</code></td>\n<td>an error occurred during SOCKS5 proxy negotiation.</td>\n</tr>\n<tr>\n<td><code>HTTPParserError</code></td>\n<td><code>HPE_*</code></td>\n<td>an error occurred while parsing the HTTP response (extends <code>Error</code>, not <code>UndiciError</code>).</td>\n</tr>\n</tbody>\n</table>\n<p>Be aware of the possible difference between the global dispatcher version and the actual undici version you might be using. We recommend to avoid the check <code>instanceof errors.UndiciError</code> and seek for the <code>error.code === '&#x3C;error_code>'</code> instead to avoid inconsistencies.</p>",
      "modules": [
        {
          "textRaw": "`ConnectTimeoutError`",
          "name": "`connecttimeouterror`",
          "type": "module",
          "desc": "<p>When <code>autoSelectFamily</code> is enabled and every attempted address fails with a timeout, Node raises an <code>AggregateError</code>. Undici surfaces these multi-address timeouts as <code>ConnectTimeoutError</code> (so the error shape is the same regardless of whether Node's family-attempt timer or undici's <code>connectTimeout</code> wins the race); the original <code>AggregateError</code> is preserved on <code>error.cause</code>.</p>",
          "displayName": "`ConnectTimeoutError`"
        },
        {
          "textRaw": "`SocketError`",
          "name": "`socketerror`",
          "type": "module",
          "desc": "<p>The <code>SocketError</code> has a <code>.socket</code> property which holds socket metadata:</p>\n<pre><code class=\"language-ts\">interface SocketInfo {\n  localAddress?: string\n  localPort?: number\n  remoteAddress?: string\n  remotePort?: number\n  remoteFamily?: string\n  timeout?: number\n  bytesWritten?: number\n  bytesRead?: number\n}\n</code></pre>\n<p>Be aware that in some cases the <code>.socket</code> property can be <code>null</code>.</p>",
          "displayName": "`SocketError`"
        }
      ],
      "displayName": "Errors"
    }
  ]
}