From 4cc65c4ec5cb263926620644ca3a08485b245698 Mon Sep 17 00:00:00 2001 From: sta Date: Mon, 14 Aug 2017 15:18:20 +0900 Subject: [PATCH] [Modify] Polish it --- websocket-sharp/WebSocket.cs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index 7e262241..6a5c5ceb 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -3226,22 +3226,28 @@ namespace WebSocketSharp if (stream == null) throw new ArgumentNullException ("stream"); - if (!stream.CanRead) - throw new ArgumentException ("It cannot be read.", "stream"); + if (!stream.CanRead) { + var msg = "It cannot be read."; + throw new ArgumentException (msg, "stream"); + } - if (length < 1) - throw new ArgumentException ("It is less than 1.", "length"); + if (length < 1) { + var msg = "Less than 1."; + throw new ArgumentException (msg, "length"); + } var bytes = stream.ReadBytes (length); var len = bytes.Length; - if (len == 0) - throw new ArgumentException ("No data could be read from it.", "stream"); + if (len == 0) { + var msg = "No data could be read from it."; + throw new ArgumentException (msg, "stream"); + } if (len < length) { _logger.Warn ( String.Format ( - "Only {0} byte(s) of data could be read from the specified stream.", + "Only {0} byte(s) of data could be read from the stream.", len ) );