diff --git a/lib/dgram.js b/lib/dgram.js index 0d93ca28748e87..55753b177279a9 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 b7d1e01b321ac7..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 "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 c061fbc1870d9e..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 "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