From 0a3f474f0e9e9d3e6abc5ab462036cd771bce0fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Sat, 17 Jun 2017 15:59:20 +0200 Subject: [PATCH 1/2] dgram: change parameter name in set(Multicast)TTL Changed the parameter name in set(Multicast)TTL from "arg" to "ttl" both within code and error messages. --- lib/dgram.js | 20 ++++++++++---------- test/parallel/test-dgram-multicast-setTTL.js | 2 +- test/parallel/test-dgram-setTTL.js | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/dgram.js b/lib/dgram.js index 0d93ca28748e87..2ce1fec155f62e 100644 --- a/lib/dgram.js +++ b/lib/dgram.js @@ -524,35 +524,35 @@ Socket.prototype.setBroadcast = function(arg) { }; -Socket.prototype.setTTL = function(arg) { - if (typeof arg !== 'number') { +Socket.prototype.setTTL = function(ttl) { + if (typeof ttl !== 'number') { throw new errors.TypeError('ERR_INVALID_ARG_TYPE', - 'arg', + 'ttl', 'number'); } - var err = this._handle.setTTL(arg); + var err = this._handle.setTTL(ttl); if (err) { throw errnoException(err, 'setTTL'); } - return arg; + return ttl; }; -Socket.prototype.setMulticastTTL = function(arg) { - if (typeof arg !== 'number') { +Socket.prototype.setMulticastTTL = function(ttl) { + if (typeof ttl !== 'number') { throw new errors.TypeError('ERR_INVALID_ARG_TYPE', - 'arg', + 'ttl', 'number'); } - var err = this._handle.setMulticastTTL(arg); + var err = this._handle.setMulticastTTL(ttl); if (err) { throw errnoException(err, 'setMulticastTTL'); } - return arg; + return ttl; }; diff --git a/test/parallel/test-dgram-multicast-setTTL.js b/test/parallel/test-dgram-multicast-setTTL.js index b7d1e01b321ac7..9b6e469e492215 100644 --- a/test/parallel/test-dgram-multicast-setTTL.js +++ b/test/parallel/test-dgram-multicast-setTTL.js @@ -40,7 +40,7 @@ socket.on('listening', common.mustCall(() => { }, common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError, - message: /^The "arg" argument must be of type number$/ + message: /^The "ttl" argument must be of type number$/ })); //close the socket diff --git a/test/parallel/test-dgram-setTTL.js b/test/parallel/test-dgram-setTTL.js index c061fbc1870d9e..d2dfaab550c380 100644 --- a/test/parallel/test-dgram-setTTL.js +++ b/test/parallel/test-dgram-setTTL.js @@ -14,7 +14,7 @@ socket.on('listening', common.mustCall(() => { }, common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError, - message: /^The "arg" argument must be of type number$/ + message: /^The "ttl" argument must be of type number$/ })); // TTL must be a number from > 0 to < 256 From aaa7470cecc70f4d10130c9a4543194e18db0ba5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Sun, 18 Jun 2017 13:36:29 +0200 Subject: [PATCH 2/2] Add actual argument --- lib/dgram.js | 8 ++------ test/parallel/test-dgram-multicast-setTTL.js | 2 +- test/parallel/test-dgram-setTTL.js | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/dgram.js b/lib/dgram.js index 2ce1fec155f62e..55753b177279a9 100644 --- a/lib/dgram.js +++ b/lib/dgram.js @@ -526,9 +526,7 @@ Socket.prototype.setBroadcast = function(arg) { Socket.prototype.setTTL = function(ttl) { if (typeof ttl !== 'number') { - throw new errors.TypeError('ERR_INVALID_ARG_TYPE', - 'ttl', - 'number'); + throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'ttl', 'number', ttl); } var err = this._handle.setTTL(ttl); @@ -542,9 +540,7 @@ Socket.prototype.setTTL = function(ttl) { Socket.prototype.setMulticastTTL = function(ttl) { if (typeof ttl !== 'number') { - throw new errors.TypeError('ERR_INVALID_ARG_TYPE', - 'ttl', - 'number'); + throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'ttl', 'number', ttl); } var err = this._handle.setMulticastTTL(ttl); diff --git a/test/parallel/test-dgram-multicast-setTTL.js b/test/parallel/test-dgram-multicast-setTTL.js index 9b6e469e492215..bd04ce4f32bde6 100644 --- a/test/parallel/test-dgram-multicast-setTTL.js +++ b/test/parallel/test-dgram-multicast-setTTL.js @@ -40,7 +40,7 @@ socket.on('listening', common.mustCall(() => { }, common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError, - message: /^The "ttl" argument must be of type number$/ + message: 'The "ttl" argument must be of type number. Received type string' })); //close the socket diff --git a/test/parallel/test-dgram-setTTL.js b/test/parallel/test-dgram-setTTL.js index d2dfaab550c380..840a3f4d09f43a 100644 --- a/test/parallel/test-dgram-setTTL.js +++ b/test/parallel/test-dgram-setTTL.js @@ -14,7 +14,7 @@ socket.on('listening', common.mustCall(() => { }, common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError, - message: /^The "ttl" argument must be of type number$/ + message: 'The "ttl" argument must be of type number. Received type string' })); // TTL must be a number from > 0 to < 256