aboutsummaryrefslogtreecommitdiff
path: root/lib/internal/util.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/internal/util.js')
-rw-r--r--lib/internal/util.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/internal/util.js b/lib/internal/util.js
index 414d037a29..ee550fad2e 100644
--- a/lib/internal/util.js
+++ b/lib/internal/util.js
@@ -12,6 +12,9 @@ const {
arrow_message_private_symbol: kArrowMessagePrivateSymbolIndex,
decorated_private_symbol: kDecoratedPrivateSymbolIndex
} = internalBinding('util');
+const {
+ isNativeError
+} = internalBinding('types');
const { errmap } = internalBinding('uv');
@@ -26,7 +29,10 @@ function removeColors(str) {
}
function isError(e) {
- return objectToString(e) === '[object Error]' || e instanceof Error;
+ // An error could be an instance of Error while not being a native error
+ // or could be from a different realm and not be instance of Error but still
+ // be a native error.
+ return isNativeError(e) || e instanceof Error;
}
function objectToString(o) {