From 1113b81dc758f08b8f64e44c8a704ccb9620df19 Mon Sep 17 00:00:00 2001 From: "Giovanny Andres Gongora Granada (Gioyik)" Date: Sat, 22 Sep 2018 02:28:03 -0500 Subject: [PATCH] errors: fix ERR_SOCKET_BAD_PORT message The current message says 'Port should be > 0' meaning '0' is an invalid value. You can pass '0' to get a random port from the system. The correct message for this error is 'Port should be >= 0'. --- doc/api/errors.md | 2 +- lib/internal/errors.js | 2 +- test/parallel/test-dns.js | 2 +- test/parallel/test-internal-errors.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/api/errors.md b/doc/api/errors.md index 139bc9a825280d..ccbf0e5381889a 100644 --- a/doc/api/errors.md +++ b/doc/api/errors.md @@ -1521,7 +1521,7 @@ An invalid (negative) size was passed for either the `recvBufferSize` or ### ERR_SOCKET_BAD_PORT -An API function expecting a port > 0 and < 65536 received an invalid value. +An API function expecting a port >= 0 and < 65536 received an invalid value. ### ERR_SOCKET_BAD_TYPE diff --git a/lib/internal/errors.js b/lib/internal/errors.js index e3c5a2b0b68559..00fcc5206213e5 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -801,7 +801,7 @@ E('ERR_SOCKET_ALREADY_BOUND', 'Socket is already bound', Error); E('ERR_SOCKET_BAD_BUFFER_SIZE', 'Buffer size must be a positive integer', TypeError); E('ERR_SOCKET_BAD_PORT', - 'Port should be > 0 and < 65536. Received %s.', RangeError); + 'Port should be >= 0 and < 65536. Received %s.', RangeError); E('ERR_SOCKET_BAD_TYPE', 'Bad socket type specified. Valid types are: udp4, udp6', TypeError); E('ERR_SOCKET_BUFFER_SIZE', diff --git a/test/parallel/test-dns.js b/test/parallel/test-dns.js index dcef59e43f90a1..a618bccd89ac13 100644 --- a/test/parallel/test-dns.js +++ b/test/parallel/test-dns.js @@ -290,7 +290,7 @@ const portErr = (port) => { const err = { code: 'ERR_SOCKET_BAD_PORT', message: - `Port should be > 0 and < 65536. Received ${port}.`, + `Port should be >= 0 and < 65536. Received ${port}.`, type: RangeError }; diff --git a/test/parallel/test-internal-errors.js b/test/parallel/test-internal-errors.js index 8e66cb3521d356..3a311819f9d9cd 100644 --- a/test/parallel/test-internal-errors.js +++ b/test/parallel/test-internal-errors.js @@ -129,7 +129,7 @@ assert.strictEqual(errors.getMessage('ERR_MISSING_ARGS', ['a', 'b', 'c']), // Test ERR_SOCKET_BAD_PORT assert.strictEqual( errors.getMessage('ERR_SOCKET_BAD_PORT', [0]), - 'Port should be > 0 and < 65536. Received 0.'); + 'Port should be >= 0 and < 65536. Received 0.'); // Test ERR_TLS_CERT_ALTNAME_INVALID assert.strictEqual(