summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Nießen <tniessen@tnie.de>2017-06-17 15:59:20 +0200
committerAnna Henningsen <anna@addaleax.net>2017-06-21 22:44:22 +0200
commit1fe455f52549e7122b9afcf47f67ca40341cdf56 (patch)
tree08ef1c85cb051b53432dcc73f51d212b77d0c58e
parent3306fd1d97754dd01859619ab8ce47a956445151 (diff)
downloadnode-new-1fe455f52549e7122b9afcf47f67ca40341cdf56.tar.gz
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 and added the actual type of the argument to the error message. PR-URL: https://github.com/nodejs/node/pull/13747 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
-rw-r--r--lib/dgram.js24
-rw-r--r--test/parallel/test-dgram-multicast-setTTL.js2
-rw-r--r--test/parallel/test-dgram-setTTL.js2
3 files changed, 12 insertions, 16 deletions
diff --git a/lib/dgram.js b/lib/dgram.js
index 0d93ca2874..55753b1772 100644
--- a/lib/dgram.js
+++ b/lib/dgram.js
@@ -524,35 +524,31 @@ Socket.prototype.setBroadcast = function(arg) {
};
-Socket.prototype.setTTL = function(arg) {
- if (typeof arg !== 'number') {
- throw new errors.TypeError('ERR_INVALID_ARG_TYPE',
- 'arg',
- 'number');
+Socket.prototype.setTTL = function(ttl) {
+ if (typeof ttl !== 'number') {
+ throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'ttl', 'number', ttl);
}
- 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') {
- throw new errors.TypeError('ERR_INVALID_ARG_TYPE',
- 'arg',
- 'number');
+Socket.prototype.setMulticastTTL = function(ttl) {
+ if (typeof ttl !== 'number') {
+ throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'ttl', 'number', ttl);
}
- 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 b7d1e01b32..bd04ce4f32 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. Received type string'
}));
//close the socket
diff --git a/test/parallel/test-dgram-setTTL.js b/test/parallel/test-dgram-setTTL.js
index c061fbc187..840a3f4d09 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. Received type string'
}));
// TTL must be a number from > 0 to < 256