From 34f9ba17de450f98f333efaf7788f726f1271f4d Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 13 May 2025 10:54:36 +0900 Subject: [PATCH] [Modify] Throw an exception --- websocket-sharp/WebSocket.cs | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7553a841..5ce1e677 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3964,23 +3964,29 @@ namespace WebSocketSharp /// /// Sets an HTTP cookie to send with the handshake request. /// - /// - /// This method works if the current state of the interface is - /// New or Closed. - /// /// /// A that specifies the cookie to send. /// - /// - /// The interface is not for the client. - /// /// /// is . /// + /// + /// + /// The SetCookie method is not available if the interface is not for + /// the client. + /// + /// + /// -or- + /// + /// + /// The SetCookie method is not available when the current state of + /// the interface is neither New nor Closed. + /// + /// public void SetCookie (Cookie cookie) { if (!_isClient) { - var msg = "The interface is not for the client."; + var msg = "The SetCookie method is not available."; throw new InvalidOperationException (msg); } @@ -3989,8 +3995,11 @@ namespace WebSocketSharp throw new ArgumentNullException ("cookie"); lock (_forState) { - if (!canSet ()) - return; + if (!canSet ()) { + var msg = "The SetCookie method is not available."; + + throw new InvalidOperationException (msg); + } lock (_cookies.SyncRoot) _cookies.SetOrRemove (cookie);