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>
This commit is contained in:
parent
a0f7284346
commit
279fcc44fa
24
lib/dgram.js
24
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;
|
||||
};
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user