Skip to content

Commit 61461e4

Browse files
committed
fix: replace ErrorIsError with isNativeError for better error serialization
1 parent 1a76b7f commit 61461e4

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

lib/internal/logger/serializers.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
'use strict';
2-
const {
3-
ErrorIsError,
4-
} = primordials;
2+
const { isNativeError } = require('internal/util/types');
53

64
/**
75
* Serializes an Error object
86
* @param {Error} error
97
* @returns {object}
108
*/
119
function serializeErr(error) {
12-
if (!ErrorIsError(error)) {
10+
if (!isNativeError(error)) {
1311
return error;
1412
}
1513

lib/logger.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ const {
99
SafeSet,
1010
} = primordials;
1111

12+
// Add isNativeError from internal/util/types
13+
const { isNativeError } = require('internal/util/types');
14+
1215

1316
const {
1417
codes: {
@@ -384,7 +387,7 @@ class Logger {
384387
* @private
385388
*/
386389
#isError(value) {
387-
return value instanceof Error;
390+
return isNativeError(value);
388391
}
389392

390393
/**

0 commit comments

Comments
 (0)