From dc379626ab0486a63f20dd98d0651918a918fc76 Mon Sep 17 00:00:00 2001 From: marco-ippolito Date: Mon, 29 Apr 2024 11:22:43 +0200 Subject: [PATCH] util: move util.isError to eol MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/52744 Reviewed-By: Benjamin Gruenbaum Reviewed-By: Yagiz Nizipli Reviewed-By: Matteo Collina Reviewed-By: Rafael Gonzaga Reviewed-By: Ulises Gascón Reviewed-By: Paolo Insogna Reviewed-By: Trivikram Kamat Reviewed-By: Moshe Atlow Reviewed-By: James M Snell --- doc/api/deprecations.md | 9 ++++---- doc/api/util.md | 43 -------------------------------------- lib/util.js | 15 ------------- test/parallel/test-util.js | 14 ------------- 4 files changed, 5 insertions(+), 76 deletions(-) diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index e71db997dc9a4f..48d018fc6df310 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -1077,6 +1077,9 @@ The `util.isDate()` API has been removed. Please use -Type: Runtime +Type: End-of-Life -The [`util.isError()`][] API is deprecated. Please use +The `util.isError()` API has been removed. Please use `Object.prototype.toString(arg) === '[object Error]' || arg instanceof Error` instead. @@ -3809,8 +3812,6 @@ is deprecated to better align with recommendations per [NIST SP 800-38D][]. [`util.inspect()`]: util.md#utilinspectobject-options [`util.inspect.custom`]: util.md#utilinspectcustom [`util.isArray()`]: util.md#utilisarrayobject -[`util.isError()`]: util.md#utiliserrorobject -[`util.isFunction()`]: util.md#utilisfunctionobject [`util.isPrimitive()`]: util.md#utilisprimitiveobject [`util.log()`]: util.md#utillogstring [`util.promisify`]: util.md#utilpromisifyoriginal diff --git a/doc/api/util.md b/doc/api/util.md index 2da1963e59069b..2635a60d878bc3 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -2950,47 +2950,6 @@ util.isArray({}); // Returns: false ``` -### `util.isError(object)` - - - -> Stability: 0 - Deprecated: Use [`util.types.isNativeError()`][] instead. - -* `object` {any} -* Returns: {boolean} - -Returns `true` if the given `object` is an [`Error`][]. Otherwise, returns -`false`. - -```js -const util = require('node:util'); - -util.isError(new Error()); -// Returns: true -util.isError(new TypeError()); -// Returns: true -util.isError({ name: 'Error', message: 'an error occurred' }); -// Returns: false -``` - -This method relies on `Object.prototype.toString()` behavior. It is -possible to obtain an incorrect result when the `object` argument manipulates -`@@toStringTag`. - -```js -const util = require('node:util'); -const obj = { name: 'Error', message: 'an error occurred' }; - -util.isError(obj); -// Returns: false -obj[Symbol.toStringTag] = 'Error'; -util.isError(obj); -// Returns: true -``` - ### `util.isFunction(object)`