diff --git a/lib/internal/errors.js b/lib/internal/errors.js index b162f961041221..5677b9af679f33 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -1569,7 +1569,7 @@ E('ERR_SOCKET_BAD_PORT', (name, port, allowZero = true) => { assert(typeof allowZero === 'boolean', "The 'allowZero' argument must be of type boolean."); const operator = allowZero ? '>=' : '>'; - return `${name} should be ${operator} 0 and < 65536. Received ${port}.`; + return `${name} should be ${operator} 0 and < 65536. Received ${determineSpecificType(port)}.`; }, RangeError); E('ERR_SOCKET_BAD_TYPE', 'Bad socket type specified. Valid types are: udp4, udp6', TypeError); diff --git a/test/parallel/test-dns.js b/test/parallel/test-dns.js index 18218308486f4e..b324723ce9a8f4 100644 --- a/test/parallel/test-dns.js +++ b/test/parallel/test-dns.js @@ -310,8 +310,6 @@ dns.lookup('', { const portErr = (port) => { const err = { code: 'ERR_SOCKET_BAD_PORT', - message: - `Port should be >= 0 and < 65536. Received ${port}.`, name: 'RangeError' }; @@ -323,10 +321,7 @@ const portErr = (port) => { dns.lookupService('0.0.0.0', port, common.mustNotCall()); }, err); }; -portErr(null); -portErr(undefined); -portErr(65538); -portErr('test'); +[null, undefined, 65538, 'test', NaN, Infinity, Symbol(), 0n, true, false, '', () => {}, {}].forEach(portErr); assert.throws(() => { dns.lookupService('0.0.0.0', 80, null);