From d72c65adfe70c97aacb2aa09c81f17732ac5354a Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Sun, 10 Sep 2023 01:02:18 +0200 Subject: [PATCH] errors: use `determineSpecificType` in more error messages --- 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 bed02da76a3bab..28c241f6fedda9 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -1349,17 +1349,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);