From 7c69c33acc046959842baa9fe2b457208f0a7c1e Mon Sep 17 00:00:00 2001 From: Marco Ippolito Date: Tue, 31 Oct 2023 12:46:05 +0200 Subject: [PATCH] util: runtime deprecate util.isError PR-URL: https://github.com/nodejs/node/pull/50488 Reviewed-By: Rafael Gonzaga Reviewed-By: Yagiz Nizipli Reviewed-By: Robert Nagy Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Joyee Cheung --- doc/api/deprecations.md | 9 +++++++-- lib/util.js | 8 ++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index a1d87b956d2b14..b35e4b4e4cf0ff 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -1058,6 +1058,9 @@ The [`util.isDate()`][] API is deprecated. -Type: Documentation-only +Type: Runtime -The [`util.isError()`][] API is deprecated. +The [`util.isError()`][] API is deprecated. Please use +`Object.prototype.toString(arg) === '[object Error]' || arg instanceof Error` +instead. ### DEP0049: `util.isFunction()` diff --git a/lib/util.js b/lib/util.js index 4f66b9ee8f9dc5..12b9c5d7c670c5 100644 --- a/lib/util.js +++ b/lib/util.js @@ -430,9 +430,13 @@ module.exports = { 'The `util.isObject` API is deprecated. Please use `typeof arg === "object"` instead.', 'DEP0053'), isDate: deprecate(types.isDate, - 'The `util.isDate` API is deprecated. Please use `arg instanceof Error` instead.', + 'The `util.isDate API is deprecated. Please use `arg instanceof Error` instead.', 'DEP0047'), - isError: deprecate(isError, 'The `util.isError API is deprecated.', 'DEP0048'), + isError: deprecate(isError, + 'The `util.isError` API is deprecated. ' + + 'Please use `ObjectPrototypeToString(e) === "[object Error]" ' + + '|| e instanceof Error` instead.', + 'DEP0048'), isFunction: deprecate(isFunction, 'The `util.isFunction API is deprecated.', 'DEP0049'), isPrimitive: deprecate(isPrimitive, 'The `util.isPrimitive API is deprecated.', 'DEP0054'), log: deprecate(log, 'The `util.log API is deprecated.', 'DEP0059'),