From eac39656fd6c7bb660d0edd403562dc92aa61eda Mon Sep 17 00:00:00 2001 From: sta Date: Fri, 5 Apr 2019 16:03:11 +0900 Subject: [PATCH] [Modify] Polish it --- websocket-sharp/Net/CookieCollection.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/websocket-sharp/Net/CookieCollection.cs b/websocket-sharp/Net/CookieCollection.cs index 3a86a32a..70f54221 100644 --- a/websocket-sharp/Net/CookieCollection.cs +++ b/websocket-sharp/Net/CookieCollection.cs @@ -569,13 +569,16 @@ namespace WebSocketSharp.Net if (array.Rank > 1) throw new ArgumentException ("Multidimensional.", "array"); - if (array.Length - index < _list.Count) - throw new ArgumentException ( - "The number of elements in this collection is greater than the available space of the destination array."); + if (array.Length - index < _list.Count) { + var msg = "The available space of the array is not enough to copy to."; + throw new ArgumentException (msg); + } - if (!array.GetType ().GetElementType ().IsAssignableFrom (typeof (Cookie))) - throw new InvalidCastException ( - "The elements in this collection cannot be cast automatically to the type of the destination array."); + var elmType = array.GetType ().GetElementType (); + if (!elmType.IsAssignableFrom (typeof (Cookie))) { + var msg = "The element type of the array cannot be assigned."; + throw new InvalidCastException (msg); + } ((IList) _list).CopyTo (array, index); }