[Modify] Throw exceptions

This commit is contained in:
sta 2017-07-23 17:40:21 +09:00
parent 0c360fbf37
commit dfb8746cdf

View File

@ -2449,12 +2449,19 @@ namespace WebSocketSharp
/// </param> /// </param>
public void Close (ushort code) public void Close (ushort code)
{ {
string msg; if (!code.IsCloseStatusCode ()) {
if (!CheckParametersForClose (code, null, _client, out msg)) { var msg = "Less than 1000 or greater than 4999.";
_logger.Error (msg); throw new ArgumentOutOfRangeException ("code", msg);
error ("An error has occurred in closing the connection.", null); }
return; if (_client && code == 1011) {
var msg = "1011 cannot be used.";
throw new ArgumentException (msg, "code");
}
if (!_client && code == 1010) {
var msg = "1010 cannot be used.";
throw new ArgumentException (msg, "code");
} }
close (code, String.Empty); close (code, String.Empty);