Skip to content

Commit

Permalink
dgram: change parameter name in set(Multicast)TTL
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
tniessen committed Jun 20, 2017
1 parent a0f7284 commit 279fcc4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
24 changes: 10 additions & 14 deletions lib/dgram.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};


Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-dgram-multicast-setTTL.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-dgram-setTTL.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 279fcc4

Please sign in to comment.