| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ca53f02 commit 44d03e8
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -856,13 +856,11 @@ Socket.prototype.addSourceSpecificMembership = function(sourceAddress, | |||
| 856 | 856 | healthCheck(this); | |
| 857 | 857 | ||
| 858 | 858 | if (typeof sourceAddress !== 'string') { | |
| 859 | - throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'sourceAddress', | ||
| 860 | - 'string'); | ||
| 859 | + throw new ERR_INVALID_ARG_TYPE('sourceAddress', 'string', sourceAddress); | ||
| 861 | 860 | } | |
| 862 | 861 | ||
| 863 | 862 | if (typeof groupAddress !== 'string') { | |
| 864 | - throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'groupAddress', | ||
| 865 | - 'string'); | ||
| 863 | + throw new ERR_INVALID_ARG_TYPE('groupAddress', 'string', groupAddress); | ||
| 866 | 864 | } | |
| 867 | 865 | ||
| 868 | 866 | const err = | |
@@ -881,13 +879,11 @@ Socket.prototype.dropSourceSpecificMembership = function(sourceAddress, | |||
| 881 | 879 | healthCheck(this); | |
| 882 | 880 | ||
| 883 | 881 | if (typeof sourceAddress !== 'string') { | |
| 884 | - throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'sourceAddress', | ||
| 885 | - 'string'); | ||
| 882 | + throw new ERR_INVALID_ARG_TYPE('sourceAddress', 'string', sourceAddress); | ||
| 886 | 883 | } | |
| 887 | 884 | ||
| 888 | 885 | if (typeof groupAddress !== 'string') { | |
| 889 | - throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'groupAddress', | ||
| 890 | - 'string'); | ||
| 886 | + throw new ERR_INVALID_ARG_TYPE('groupAddress', 'string', groupAddress); | ||
| 891 | 887 | } | |
| 892 | 888 | ||
| 893 | 889 | const err = | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -76,3 +76,79 @@ const setup = dgram.createSocket.bind(dgram, { type: 'udp4', reuseAddr: true }); | |||
| 76 | 76 | /^Error: dropMembership EINVAL$/); | |
| 77 | 77 | socket.close(); | |
| 78 | 78 | } | |
| 79 | + | ||
| 80 | + // addSourceSpecificMembership with invalid sourceAddress should throw | ||
| 81 | + { | ||
| 82 | + const socket = setup(); | ||
| 83 | + assert.throws(() => { | ||
| 84 | + socket.addSourceSpecificMembership(0, multicastAddress); | ||
| 85 | + }, { | ||
| 86 | + code: 'ERR_INVALID_ARG_TYPE', | ||
| 87 | + message: 'The "sourceAddress" argument must be of type string. ' + | ||
| 88 | + 'Received type number (0)' | ||
| 89 | + }); | ||
| 90 | + socket.close(); | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + // addSourceSpecificMembership with invalid sourceAddress should throw | ||
| 94 | + { | ||
| 95 | + const socket = setup(); | ||
| 96 | + assert.throws(() => { | ||
| 97 | + socket.addSourceSpecificMembership(multicastAddress, 0); | ||
| 98 | + }, { | ||
| 99 | + code: 'ERR_INVALID_ARG_TYPE', | ||
| 100 | + message: 'The "groupAddress" argument must be of type string. ' + | ||
| 101 | + 'Received type number (0)' | ||
| 102 | + }); | ||
| 103 | + socket.close(); | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + // addSourceSpecificMembership with invalid groupAddress should throw | ||
| 107 | + { | ||
| 108 | + const socket = setup(); | ||
| 109 | + assert.throws(() => { | ||
| 110 | + socket.addSourceSpecificMembership(multicastAddress, '0'); | ||
| 111 | + }, { | ||
| 112 | + code: 'EINVAL', | ||
| 113 | + message: 'addSourceSpecificMembership EINVAL' | ||
| 114 | + }); | ||
| 115 | + socket.close(); | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + // dropSourceSpecificMembership with invalid sourceAddress should throw | ||
| 119 | + { | ||
| 120 | + const socket = setup(); | ||
| 121 | + assert.throws(() => { | ||
| 122 | + socket.dropSourceSpecificMembership(0, multicastAddress); | ||
| 123 | + }, { | ||
| 124 | + code: 'ERR_INVALID_ARG_TYPE', | ||
| 125 | + message: 'The "sourceAddress" argument must be of type string. ' + | ||
| 126 | + 'Received type number (0)' | ||
| 127 | + }); | ||
| 128 | + socket.close(); | ||
| 129 | + } | ||
| 130 | + | ||
| 131 | + // dropSourceSpecificMembership with invalid groupAddress should throw | ||
| 132 | + { | ||
| 133 | + const socket = setup(); | ||
| 134 | + assert.throws(() => { | ||
| 135 | + socket.dropSourceSpecificMembership(multicastAddress, 0); | ||
| 136 | + }, { | ||
| 137 | + code: 'ERR_INVALID_ARG_TYPE', | ||
| 138 | + message: 'The "groupAddress" argument must be of type string. ' + | ||
| 139 | + 'Received type number (0)' | ||
| 140 | + }); | ||
| 141 | + socket.close(); | ||
| 142 | + } | ||
| 143 | + | ||
| 144 | + // dropSourceSpecificMembership with invalid UDP should throw | ||
| 145 | + { | ||
| 146 | + const socket = setup(); | ||
| 147 | + assert.throws(() => { | ||
| 148 | + socket.dropSourceSpecificMembership(multicastAddress, '0'); | ||
| 149 | + }, { | ||
| 150 | + code: 'EINVAL', | ||
| 151 | + message: 'dropSourceSpecificMembership EINVAL' | ||
| 152 | + }); | ||
| 153 | + socket.close(); | ||
| 154 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments