From 8ca9338655dc3635da0d8fe154c5262468eb545f Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Wed, 21 Jun 2017 20:14:45 +0200 Subject: [PATCH] doc: document missing error types PR-URL: https://github.com/nodejs/node/pull/13857 Reviewed-By: Refael Ackermann Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Michael Dawson --- doc/api/errors.md | 106 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 94 insertions(+), 12 deletions(-) diff --git a/doc/api/errors.md b/doc/api/errors.md index 6eeef46045bd82..20f877c92dc966 100644 --- a/doc/api/errors.md +++ b/doc/api/errors.md @@ -568,22 +568,51 @@ found [here][online]. Used generically to identify that an iterable argument (i.e. a value that works with `for...of` loops) is required, but not provided to a Node.js API. + +### ERR_ASSERTION + +Used as special type of error that can be triggered whenever Node.js detects an +exceptional logic violation that should never occur. These are raised typically +by the `assert` module. + ### ERR_CONSOLE_WRITABLE_STREAM Used when `Console` is instantiated without `stdout` stream or when `stdout` or `stderr` streams are not writable. + +### ERR_CPU_USAGE + +Used when the native call from `process.cpuUsage` cannot be processed properly. + ### ERR_FALSY_VALUE_REJECTION Used by the `util.callbackify()` API when a callbackified `Promise` is rejected with a falsy value (e.g. `null`). + +### ERR_HTTP_HEADERS_SENT + +Used when headers have already been sent and another attempt is made to add +more headers. + + +### ERR_HTTP_INVALID_STATUS_CODE + +Used for status codes outside the regular status code ranges (100-999). + + +### ERR_HTTP_TRAILER_INVALID + +Used when the `Trailer` header is set even though the transfer encoding does not +support that. + ### ERR_INDEX_OUT_OF_RANGE -Used when a given index is out of the accepted range. +Used when a given index is out of the accepted range (e.g. negative offsets). ### ERR_INVALID_ARG_TYPE @@ -591,18 +620,33 @@ Used when a given index is out of the accepted range. Used generically to identify that an argument of the wrong type has been passed to a Node.js API. + +### ERR_INVALID_ARRAY_LENGTH + +Used when an Array is not of the expected length or in a valid range. + ### ERR_INVALID_CALLBACK Used generically to identify that a callback function is required and has not been provided to a Node.js API. + +### ERR_INVALID_CHAR + +Used when invalid characters are detected in headers. + ### ERR_INVALID_CURSOR_POS The `'ERR_INVALID_CURSOR_POS'` is thrown specifically when a cursor on a given stream is attempted to move to a specified row without a specified column. + +### ERR_INVALID_FD + +Used when a file descriptor ('fd') is not valid (e.g. it has a negative value). + ### ERR_INVALID_FILE_URL_HOST @@ -638,6 +682,12 @@ passed in an options object. Used when both `breakEvalOnSigint` and `eval` options are set in the REPL config, which is not supported. + +### ERR_INVALID_REPL_HISTORY + +Used in the `repl` in case the old history file is used and an error occurred +while trying to read and parse it. + ### ERR_INVALID_SYNC_FORK_INPUT @@ -716,14 +766,33 @@ synchronous forked Node.js process. See the documentation for the ### ERR_MISSING_ARGS -Used when a required argument of a Node.js API is not passed. This is currently -only used in the [WHATWG URL API][] for strict compliance with the specification -(which in some cases may accept `func(undefined)` but not `func()`). In most -native Node.js APIs, `func(undefined)` and `func()` are treated identically, and -the [`ERR_INVALID_ARG_TYPE`][] error code may be used instead. +Used when a required argument of a Node.js API is not passed. This is only used +for strict compliance with the API specification (which in some cases may accept +`func(undefined)` but not `func()`). In most native Node.js APIs, +`func(undefined)` and `func()` are treated identically, and the +[`ERR_INVALID_ARG_TYPE`][] error code may be used instead. + + +### ERR_MULTIPLE_CALLBACK + +Used when a callback is called more then once. + +*Note*: A callback is almost always meant to only be called once as the query +can either be fulfilled or rejected but not both at the same time. The latter +would be possible by calling a callback more then once. + + +### ERR_NO_CRYPTO + +Used when an attempt is made to use crypto features while Node.js is not +compiled with OpenSSL crypto support. + + +### ERR_PARSE_HISTORY_DATA ### ERR_SOCKET_ALREADY_BOUND + Used when an attempt is made to bind a socket that has already been bound. @@ -748,12 +817,6 @@ Used when data cannot be sent on a socket. Used when a call is made and the UDP subsystem is not running. - -### ERR_NO_CRYPTO - -Used when an attempt is made to use crypto features while Node.js is not -compiled with OpenSSL crypto support. - ### ERR_STDERR_CLOSE @@ -766,6 +829,19 @@ Node.js does not allow `stdout` or `stderr` Streams to be closed by user code. Used when an attempt is made to close the `process.stdout` stream. By design, Node.js does not allow `stdout` or `stderr` Streams to be closed by user code. + +### ERR_STREAM_HAS_STRINGDECODER + +Used to prevent an abort if a string decoder was set on the Socket. + +Example +```js +const Socket = require('net').Socket; +const instance = new Socket(); + +instance.setEncoding('utf-8'); +``` + ### ERR_UNKNOWN_BUILTIN_MODULE @@ -795,6 +871,11 @@ Used when an attempt is made to launch a Node.js process with an unknown by errors in user code, although it is not impossible. Occurrences of this error are most likely an indication of a bug within Node.js itself. + +### ERR_V8BREAKITERATOR + +Used when the V8 BreakIterator API is used but the full ICU data set is not +installed. [`ERR_INVALID_ARG_TYPE`]: #ERR_INVALID_ARG_TYPE [`child.kill()`]: child_process.html#child_process_child_kill_signal @@ -817,6 +898,7 @@ are most likely an indication of a bug within Node.js itself. [domains]: domain.html [event emitter-based]: events.html#events_class_eventemitter [file descriptors]: https://en.wikipedia.org/wiki/File_descriptor +[intl wiki]: https://github.com/nodejs/node/wiki/Intl [online]: http://man7.org/linux/man-pages/man3/errno.3.html [stream-based]: stream.html [syscall]: http://man7.org/linux/man-pages/man2/syscall.2.html