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

View File

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