summaryrefslogtreecommitdiff
path: root/lib/internal/util/inspect.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/internal/util/inspect.js')
-rw-r--r--lib/internal/util/inspect.js6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js
index 89237a09a5..9677dfb226 100644
--- a/lib/internal/util/inspect.js
+++ b/lib/internal/util/inspect.js
@@ -937,12 +937,12 @@ function getFunctionBase(value, constructor, tag) {
}
function formatError(err, constructor, tag, ctx) {
- let stack = err.stack || ErrorPrototypeToString(err);
+ const name = err.name != null ? String(err.name) : 'Error';
+ let len = name.length;
+ let stack = err.stack ? String(err.stack) : ErrorPrototypeToString(err);
// A stack trace may contain arbitrary data. Only manipulate the output
// for "regular errors" (errors that "look normal") for now.
- const name = err.name || 'Error';
- let len = name.length;
if (constructor === null ||
(name.endsWith('Error') &&
stack.startsWith(name) &&