Skip to content

Commit 7f4ca84

Browse files
committed
[Refactor] explicitly coerce Error objects to strings.
This ensures that `toString` is called over `valueOf`.
1 parent beb72d9 commit 7f4ca84

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ module.exports = function inspect_ (obj, opts, depth, seen) {
7575
parts.push(key + ': ' + inspect(obj[key]));
7676
}
7777
}
78-
if (parts.length === 0) return '[' + obj + ']';
79-
return '{ [' + obj + '] ' + parts.join(', ') + ' }';
78+
if (parts.length === 0) return '[' + String(obj) + ']';
79+
return '{ [' + String(obj) + '] ' + parts.join(', ') + ' }';
8080
}
8181
else if (typeof obj === 'object' && typeof obj.inspect === 'function') {
8282
return obj.inspect();

0 commit comments

Comments
 (0)