From 8469533c26e91abae6e3f44dfa4125a3d150a0ee Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 6 May 2025 11:41:40 +0900 Subject: [PATCH] [Modify] Throw an exception --- websocket-sharp/WebSocket.cs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 3dcfbf62..26971bbe 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -341,8 +341,17 @@ namespace WebSocketSharp /// /// /// - /// The set operation is not available if the interface is not for - /// the client. + /// + /// The set operation is not available if the interface is not for + /// the client. + /// + /// + /// -or- + /// + /// + /// The set operation is not available when the current state of + /// the interface is neither New nor Closed. + /// /// public CompressionMethod Compression { get { @@ -357,8 +366,11 @@ namespace WebSocketSharp } lock (_forState) { - if (!canSet ()) - return; + if (!canSet ()) { + var msg = "The current state of the interface is neither New nor Closed."; + + throw new InvalidOperationException (msg); + } _compression = value; }