From c679348f839fd6e02d4e944318c8afc6bd020f4e Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Tue, 12 Sep 2023 01:18:58 +0200 Subject: [PATCH] errors: use `determineSpecificType` in more error messages PR-URL: https://github.com/nodejs/node/pull/49580 Fixes: https://github.com/nodejs/node/issues/49576 Reviewed-By: Yagiz Nizipli Reviewed-By: Matthew Aitken --- lib/internal/errors.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/internal/errors.js b/lib/internal/errors.js index 6e1974b1e642b3..9fb943e3f58252 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -1354,17 +1354,11 @@ E('ERR_INVALID_REPL_EVAL_CONFIG', E('ERR_INVALID_REPL_INPUT', '%s', TypeError); E('ERR_INVALID_RETURN_PROPERTY', (input, name, prop, value) => { return `Expected a valid ${input} to be returned for the "${prop}" from the` + - ` "${name}" function but got ${value}.`; + ` "${name}" function but got ${determineSpecificType(value)}.`; }, TypeError); E('ERR_INVALID_RETURN_PROPERTY_VALUE', (input, name, prop, value) => { - let type; - if (value?.constructor?.name) { - type = `instance of ${value.constructor.name}`; - } else { - type = `type ${typeof value}`; - } return `Expected ${input} to be returned for the "${prop}" from the` + - ` "${name}" function but got ${type}.`; + ` "${name}" function but got ${determineSpecificType(value)}.`; }, TypeError); E('ERR_INVALID_RETURN_VALUE', (input, name, value) => { const type = determineSpecificType(value);