[Modify] Throw exceptions

This commit is contained in:
sta 2017-07-24 15:37:13 +09:00
parent 2306b1a925
commit eb379b6f76

View File

@ -2501,12 +2501,14 @@ namespace WebSocketSharp
/// </param> /// </param>
public void Close (CloseStatusCode code) public void Close (CloseStatusCode code)
{ {
string msg; if (_client && code == CloseStatusCode.ServerError) {
if (!CheckParametersForClose (code, null, _client, out msg)) { var msg = "ServerError cannot be used.";
_logger.Error (msg); throw new ArgumentException (msg, "code");
error ("An error has occurred in closing the connection.", null); }
return; if (!_client && code == CloseStatusCode.MandatoryExtension) {
var msg = "MandatoryExtension cannot be used.";
throw new ArgumentException (msg, "code");
} }
close ((ushort) code, String.Empty); close ((ushort) code, String.Empty);