Modified processException method

This commit is contained in:
sta 2013-11-13 16:38:13 +09:00
parent d3ba02367e
commit e9ac9a6632
2 changed files with 9 additions and 9 deletions

View File

@ -846,8 +846,7 @@ namespace WebSocketSharp
private void processException (Exception exception, string reason)
{
var code = CloseStatusCode.ABNORMAL;
var msg = reason ?? code.GetMessage ();
var msg = reason;
if (exception.GetType () == typeof (WebSocketException))
{
var wsex = (WebSocketException) exception;
@ -855,7 +854,8 @@ namespace WebSocketSharp
reason = wsex.Message;
}
if (code == CloseStatusCode.ABNORMAL)
if (code == CloseStatusCode.ABNORMAL ||
code == CloseStatusCode.TLS_HANDSHAKE_FAILURE)
{
_logger.Fatal (exception.ToString ());
reason = msg;
@ -863,14 +863,14 @@ namespace WebSocketSharp
else
{
_logger.Error (reason);
msg = code.GetMessage ();
msg = null;
}
error (msg);
error (msg ?? code.GetMessage ());
if (_readyState == WebSocketState.CONNECTING && !_client)
Close (HttpStatusCode.BadRequest);
else
close (code, reason, false);
close (code, reason ?? code.GetMessage (), false);
}
private bool processFragmentedFrame (WsFrame frame)

View File

@ -31,8 +31,8 @@ using System;
namespace WebSocketSharp
{
/// <summary>
/// Represents the exception that occurred when attempting to perform an operation on
/// the WebSocket connection.
/// Represents the exception that occurred when attempting to perform an operation
/// on the WebSocket connection.
/// </summary>
public class WebSocketException : Exception
{
@ -44,7 +44,7 @@ namespace WebSocketSharp
}
internal WebSocketException (CloseStatusCode code)
: this (code, code.GetMessage ())
: this (code, null)
{
}