[Modify] Throw exceptions
This commit is contained in:
parent
a1a09b3462
commit
db3ed340e7
@ -3716,26 +3716,24 @@ namespace WebSocketSharp
|
|||||||
/// </param>
|
/// </param>
|
||||||
public void SetCookie (Cookie cookie)
|
public void SetCookie (Cookie cookie)
|
||||||
{
|
{
|
||||||
string msg;
|
string msg = null;
|
||||||
if (!checkIfAvailable (true, false, true, false, false, true, out msg)) {
|
|
||||||
_logger.Error (msg);
|
|
||||||
error ("An error has occurred in setting a cookie.", null);
|
|
||||||
|
|
||||||
return;
|
if (!_client) {
|
||||||
|
msg = "This instance is not a client.";
|
||||||
|
throw new InvalidOperationException (msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cookie == null) {
|
if (cookie == null)
|
||||||
_logger.Error ("'cookie' is null.");
|
throw new ArgumentNullException ("cookie");
|
||||||
error ("An error has occurred in setting a cookie.", null);
|
|
||||||
|
|
||||||
|
if (!canSet (out msg)) {
|
||||||
|
_logger.Warn (msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
lock (_forState) {
|
lock (_forState) {
|
||||||
if (!checkIfAvailable (true, false, false, true, out msg)) {
|
if (!canSet (out msg)) {
|
||||||
_logger.Error (msg);
|
_logger.Warn (msg);
|
||||||
error ("An error has occurred in setting a cookie.", null);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user