Skip to content

Commit c679348

Browse files
committed
errors: use determineSpecificType in more error messages
PR-URL: #49580 Fixes: #49576 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Matthew Aitken <[email protected]>
1 parent 6ba4ebd commit c679348

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

lib/internal/errors.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,17 +1354,11 @@ E('ERR_INVALID_REPL_EVAL_CONFIG',
13541354
E('ERR_INVALID_REPL_INPUT', '%s', TypeError);
13551355
E('ERR_INVALID_RETURN_PROPERTY', (input, name, prop, value) => {
13561356
return `Expected a valid ${input} to be returned for the "${prop}" from the` +
1357-
` "${name}" function but got ${value}.`;
1357+
` "${name}" function but got ${determineSpecificType(value)}.`;
13581358
}, TypeError);
13591359
E('ERR_INVALID_RETURN_PROPERTY_VALUE', (input, name, prop, value) => {
1360-
let type;
1361-
if (value?.constructor?.name) {
1362-
type = `instance of ${value.constructor.name}`;
1363-
} else {
1364-
type = `type ${typeof value}`;
1365-
}
13661360
return `Expected ${input} to be returned for the "${prop}" from the` +
1367-
` "${name}" function but got ${type}.`;
1361+
` "${name}" function but got ${determineSpecificType(value)}.`;
13681362
}, TypeError);
13691363
E('ERR_INVALID_RETURN_VALUE', (input, name, value) => {
13701364
const type = determineSpecificType(value);

0 commit comments

Comments
 (0)