[Modify] Throw an exception if read-only

This commit is contained in:
sta 2019-04-21 17:47:05 +09:00
parent d8fd321962
commit 449e38c239

View File

@ -603,11 +603,19 @@ namespace WebSocketSharp.Net
/// <param name="cookie"> /// <param name="cookie">
/// A <see cref="Cookie"/> to add. /// A <see cref="Cookie"/> to add.
/// </param> /// </param>
/// <exception cref="InvalidOperationException">
/// The collection is read-only.
/// </exception>
/// <exception cref="ArgumentNullException"> /// <exception cref="ArgumentNullException">
/// <paramref name="cookie"/> is <see langword="null"/>. /// <paramref name="cookie"/> is <see langword="null"/>.
/// </exception> /// </exception>
public void Add (Cookie cookie) public void Add (Cookie cookie)
{ {
if (_readOnly) {
var msg = "The collection is read-only.";
throw new InvalidOperationException (msg);
}
if (cookie == null) if (cookie == null)
throw new ArgumentNullException ("cookie"); throw new ArgumentNullException ("cookie");