Skip to content

Commit 1fe455f

Browse files
tniessenaddaleax
authored andcommitted
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: #13747 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 3306fd1 commit 1fe455f

File tree

3 files changed

+12
-16
lines changed

3 files changed

+12
-16
lines changed

lib/dgram.js

+10-14
Original file line numberDiff line numberDiff line change
@@ -524,35 +524,31 @@ Socket.prototype.setBroadcast = function(arg) {
524524
};
525525

526526

527-
Socket.prototype.setTTL = function(arg) {
528-
if (typeof arg !== 'number') {
529-
throw new errors.TypeError('ERR_INVALID_ARG_TYPE',
530-
'arg',
531-
'number');
527+
Socket.prototype.setTTL = function(ttl) {
528+
if (typeof ttl !== 'number') {
529+
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'ttl', 'number', ttl);
532530
}
533531

534-
var err = this._handle.setTTL(arg);
532+
var err = this._handle.setTTL(ttl);
535533
if (err) {
536534
throw errnoException(err, 'setTTL');
537535
}
538536

539-
return arg;
537+
return ttl;
540538
};
541539

542540

543-
Socket.prototype.setMulticastTTL = function(arg) {
544-
if (typeof arg !== 'number') {
545-
throw new errors.TypeError('ERR_INVALID_ARG_TYPE',
546-
'arg',
547-
'number');
541+
Socket.prototype.setMulticastTTL = function(ttl) {
542+
if (typeof ttl !== 'number') {
543+
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'ttl', 'number', ttl);
548544
}
549545

550-
var err = this._handle.setMulticastTTL(arg);
546+
var err = this._handle.setMulticastTTL(ttl);
551547
if (err) {
552548
throw errnoException(err, 'setMulticastTTL');
553549
}
554550

555-
return arg;
551+
return ttl;
556552
};
557553

558554

test/parallel/test-dgram-multicast-setTTL.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ socket.on('listening', common.mustCall(() => {
4040
}, common.expectsError({
4141
code: 'ERR_INVALID_ARG_TYPE',
4242
type: TypeError,
43-
message: /^The "arg" argument must be of type number$/
43+
message: 'The "ttl" argument must be of type number. Received type string'
4444
}));
4545

4646
//close the socket

test/parallel/test-dgram-setTTL.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ socket.on('listening', common.mustCall(() => {
1414
}, common.expectsError({
1515
code: 'ERR_INVALID_ARG_TYPE',
1616
type: TypeError,
17-
message: /^The "arg" argument must be of type number$/
17+
message: 'The "ttl" argument must be of type number. Received type string'
1818
}));
1919

2020
// TTL must be a number from > 0 to < 256

0 commit comments

Comments
 (0)