Skip to content

Commit 239b6d1

Browse files
gnbezerraaddaleax
authored andcommitted
doc: document missing error codes
There are discrepancies between the errors defined in `lib/internal/errors.js` and those documented in `doc/api/errors.md`. Some of the errors recently defined are not documented, while others were removed, but still have entries in the docs. This commit fills in those gaps in the documentation. PR-URL: nodejs#15160 Fixes: nodejs#15038 Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent d7b1734 commit 239b6d1

File tree

1 file changed

+137
-17
lines changed

1 file changed

+137
-17
lines changed

doc/api/errors.md

+137-17
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,18 @@ Used as special type of error that can be triggered whenever Node.js detects an
588588
exceptional logic violation that should never occur. These are raised typically
589589
by the `assert` module.
590590

591+
<a id="ERR_ASYNC_CALLBACK"></a>
592+
### ERR_ASYNC_CALLBACK
593+
594+
Used with `AsyncHooks` to indicate an attempt of registering something that is
595+
not a function as a callback.
596+
597+
<a id="ERR_ASYNC_TYPE"></a>
598+
### ERR_ASYNC_TYPE
599+
600+
Used when the type of an asynchronous resource is invalid. Note that users are
601+
also able to define their own types when using the public embedder API.
602+
591603
<a id="ERR_BUFFER_OUT_OF_BOUNDS"></a>
592604
### ERR_BUFFER_OUT_OF_BOUNDS
593605

@@ -614,6 +626,18 @@ Used when the native call from `process.cpuUsage` cannot be processed properly.
614626

615627
Used when `c-ares` failed to set the DNS server.
616628

629+
<a id="ERR_ENCODING_INVALID_ENCODED_DATA"></a>
630+
### ERR_ENCODING_INVALID_ENCODED_DATA
631+
632+
Used by the `util.TextDecoder()` API when the data provided is invalid
633+
according to the encoding provided.
634+
635+
<a id="ERR_ENCODING_NOT_SUPPORTED"></a>
636+
### ERR_ENCODING_NOT_SUPPORTED
637+
638+
Used by the `util.TextDecoder()` API when the encoding provided is not one of
639+
the [WHATWG Supported Encodings][].
640+
617641
<a id="ERR_FALSY_VALUE_REJECTION"></a>
618642
### ERR_FALSY_VALUE_REJECTION
619643

@@ -626,6 +650,12 @@ with a falsy value (e.g. `null`).
626650
Used when headers have already been sent and another attempt is made to add
627651
more headers.
628652

653+
<a id="ERR_HTTP_INVALID_CHAR"></a>
654+
### ERR_HTTP_INVALID_CHAR
655+
656+
Used when an invalid character is found in an HTTP response status message
657+
(reason phrase).
658+
629659
<a id="ERR_HTTP_INVALID_STATUS_CODE"></a>
630660
### ERR_HTTP_INVALID_STATUS_CODE
631661

@@ -652,20 +682,32 @@ forbidden.
652682
<a id="ERR_HTTP2_CONNECT_SCHEME"></a>
653683
### ERR_HTTP2_CONNECT_SCHEME
654684

655-
The HTTP/2 requests using the `CONNECT` method, the `:scheme` pseudo-header is
685+
For HTTP/2 requests using the `CONNECT` method, the `:scheme` pseudo-header is
656686
forbidden.
657687

658-
<a id="ERR_HTTP2_ERROR"></a>
659-
### ERR_HTTP2_ERROR
660-
661-
A non-specific HTTP/2 error has occurred.
662-
663688
<a id="ERR_HTTP2_FRAME_ERROR"></a>
664689
### ERR_HTTP2_FRAME_ERROR
665690

666691
Used when a failure occurs sending an individual frame on the HTTP/2
667692
session.
668693

694+
<a id="ERR_HTTP2_HEADER_REQUIRED"></a>
695+
### ERR_HTTP2_HEADER_REQUIRED
696+
697+
Used when a required header is missing in an HTTP/2 message.
698+
699+
<a id="ERR_HTTP2_HEADER_SINGLE_VALUE"></a>
700+
### ERR_HTTP2_HEADER_SINGLE_VALUE
701+
702+
Used when multiple values have been provided for an HTTP header field that
703+
required to have only a single value.
704+
705+
<a id="ERR_HTTP2_HEADERS_AFTER_RESPOND"></a>
706+
### ERR_HTTP2_HEADERS_AFTER_RESPOND
707+
708+
Used when trying to specify additional headers after an HTTP/2 response
709+
initiated.
710+
669711
<a id="ERR_HTTP2_HEADERS_OBJECT"></a>
670712
### ERR_HTTP2_HEADERS_OBJECT
671713

@@ -676,12 +718,6 @@ Used when an HTTP/2 Headers Object is expected.
676718

677719
Used when an attempt is made to send multiple response headers.
678720

679-
<a id="ERR_HTTP2_HEADER_SINGLE_VALUE"></a>
680-
### ERR_HTTP2_HEADER_SINGLE_VALUE
681-
682-
Used when multiple values have been provided for an HTTP header field that
683-
required to have only a single value.
684-
685721
<a id="ERR_HTTP2_INFO_HEADERS_AFTER_RESPOND"></a>
686722
### ERR_HTTP2_INFO_HEADERS_AFTER_RESPOND
687723

@@ -837,6 +873,12 @@ to a Node.js API.
837873

838874
Used when an Array is not of the expected length or in a valid range.
839875

876+
<a id="ERR_INVALID_ASYNC_ID"></a>
877+
### ERR_INVALID_ASYNC_ID
878+
879+
Used with `AsyncHooks` when an invalid `asyncId` or `triggerAsyncId` is passed.
880+
An id less than -1 should never happen.
881+
840882
<a id="ERR_INVALID_BUFFER_SIZE"></a>
841883
### ERR_INVALID_BUFFER_SIZE
842884

@@ -913,6 +955,12 @@ passed in an options object.
913955

914956
Used when an invalid or unknown file encoding is passed.
915957

958+
<a id="ERR_INVALID_PERFORMANCE_MARK"></a>
959+
### ERR_INVALID_PERFORMANCE_MARK
960+
961+
Used by the Performance Timing API (`perf_hooks`) when a performance mark is
962+
invalid.
963+
916964
<a id="ERR_INVALID_PROTOCOL"></a>
917965
### ERR_INVALID_PROTOCOL
918966

@@ -1022,6 +1070,16 @@ Used when a callback is called more then once.
10221070
can either be fulfilled or rejected but not both at the same time. The latter
10231071
would be possible by calling a callback more then once.
10241072

1073+
<a id="ERR_NAPI_CONS_FUNCTION"></a>
1074+
### ERR_NAPI_CONS_FUNCTION
1075+
1076+
Used by the `N-API` when a constructor passed is not a function.
1077+
1078+
<a id="ERR_NAPI_CONS_PROTOTYPE_OBJECT"></a>
1079+
### ERR_NAPI_CONS_PROTOTYPE_OBJECT
1080+
1081+
Used by the `N-API` when `Constructor.prototype` is not an object.
1082+
10251083
<a id="ERR_NO_CRYPTO"></a>
10261084
### ERR_NO_CRYPTO
10271085

@@ -1041,9 +1099,17 @@ Used when a Node.js API is called in an unsupported manner.
10411099

10421100
For example: `Buffer.write(string, encoding, offset[, length])`
10431101

1102+
<a id="ERR_OUTOFMEMORY"></a>
1103+
### ERR_OUTOFMEMORY
1104+
1105+
Used generically to identify that an operation caused an out of memory
1106+
condition.
1107+
10441108
<a id="ERR_PARSE_HISTORY_DATA"></a>
10451109
### ERR_PARSE_HISTORY_DATA
10461110

1111+
Used by the `REPL` module when it cannot parse data from the REPL history file.
1112+
10471113
<a id="ERR_SOCKET_ALREADY_BOUND"></a>
10481114
### ERR_SOCKET_ALREADY_BOUND
10491115

@@ -1066,6 +1132,11 @@ invalid value.
10661132

10671133
Used when data cannot be sent on a socket.
10681134

1135+
<a id="ERR_SOCKET_CLOSED"></a>
1136+
### ERR_SOCKET_CLOSED
1137+
1138+
Used when an attempt is made to operate on an already closed socket.
1139+
10691140
<a id="ERR_SOCKET_DGRAM_NOT_RUNNING"></a>
10701141
### ERR_SOCKET_DGRAM_NOT_RUNNING
10711142

@@ -1097,12 +1168,54 @@ const instance = new Socket();
10971168
instance.setEncoding('utf-8');
10981169
```
10991170

1100-
<a id="ERR_UNKNOWN_BUILTIN_MODULE"></a>
1101-
### ERR_UNKNOWN_BUILTIN_MODULE
1171+
<a id="ERR_TLS_CERT_ALTNAME_INVALID"></a>
1172+
### ERR_TLS_CERT_ALTNAME_INVALID
1173+
1174+
Used with TLS, when the hostname/IP of the peer does not match any of the
1175+
subjectAltNames in its certificate.
1176+
1177+
<a id="ERR_TLS_DH_PARAM_SIZE"></a>
1178+
### ERR_TLS_DH_PARAM_SIZE
11021179

1103-
Used to identify a specific kind of internal Node.js error that should not
1104-
typically be triggered by user code. Instances of this error point to an
1105-
internal bug within the Node.js binary itself.
1180+
Used with TLS when the parameter offered for the Diffie-Hellman (`DH`)
1181+
key-agreement protocol is too small. By default, the key length must be greater
1182+
than or equal to 1024 bits to avoid vulnerabilities, even though it is strongly
1183+
recommended to use 2048 bits or larger for stronger security.
1184+
1185+
<a id="ERR_TLS_HANDSHAKE_TIMEOUT"></a>
1186+
### ERR_TLS_HANDSHAKE_TIMEOUT
1187+
1188+
A TLS error emitted by the server whenever a TLS/SSL handshake times out. In
1189+
this case, the server must also abort the connection.
1190+
1191+
<a id="ERR_TLS_RENEGOTIATION_FAILED"></a>
1192+
### ERR_TLS_RENEGOTIATION_FAILED
1193+
1194+
Used when a TLS renegotiation request has failed in a non-specific way.
1195+
1196+
<a id="ERR_TLS_REQUIRED_SERVER_NAME"></a>
1197+
### ERR_TLS_REQUIRED_SERVER_NAME
1198+
1199+
Used with TLS, when calling the `server.addContext()` method without providing
1200+
a hostname in the first parameter.
1201+
1202+
<a id="ERR_TLS_SESSION_ATTACK"></a>
1203+
### ERR_TLS_SESSION_ATTACK
1204+
1205+
Used when an excessive amount of TLS renegotiations is detected, which is a
1206+
potential vector for denial-of-service attacks.
1207+
1208+
<a id="ERR_TRANSFORM_ALREADY_TRANSFORMING"></a>
1209+
### ERR_TRANSFORM_ALREADY_TRANSFORMING
1210+
1211+
Used in Transform streams when the stream finishes while it is still
1212+
transforming.
1213+
1214+
<a id="ERR_TRANSFORM_WITH_LENGTH_0"></a>
1215+
### ERR_TRANSFORM_WITH_LENGTH_0
1216+
1217+
Used in Transform streams when the stream finishes with data still in the write
1218+
buffer.
11061219

11071220
<a id="ERR_UNESCAPED_CHARACTERS"></a>
11081221
### ERR_UNESCAPED_CHARACTERS
@@ -1147,6 +1260,12 @@ Used when a number value is out of range.
11471260
Used when the V8 BreakIterator API is used but the full ICU data set is not
11481261
installed.
11491262

1263+
<a id="ERR_VALID_PERFORMANCE_ENTRY_TYPE"></a>
1264+
### ERR_VALID_PERFORMANCE_ENTRY_TYPE
1265+
1266+
Used by the Performance Timing API (`perf_hooks`) when no valid performance
1267+
entry types were found.
1268+
11501269
<a id="ERR_VALUE_OUT_OF_RANGE"></a>
11511270
### ERR_VALUE_OUT_OF_RANGE
11521271

@@ -1179,3 +1298,4 @@ Used when a given value is out of the accepted range.
11791298
[syscall]: http://man7.org/linux/man-pages/man2/syscall.2.html
11801299
[try-catch]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch
11811300
[vm]: vm.html
1301+
[WHATWG Supported Encodings]: util.md#whatwg-supported-encodings

0 commit comments

Comments
 (0)