Refactored WebSocketException.cs

This commit is contained in:
sta 2014-09-09 11:08:59 +09:00
parent 66a4b2a85a
commit 5a2be24002

View File

@ -35,6 +35,12 @@ namespace WebSocketSharp
/// </summary> /// </summary>
public class WebSocketException : Exception public class WebSocketException : Exception
{ {
#region Private Fields
private CloseStatusCode _code;
#endregion
#region Internal Constructors #region Internal Constructors
internal WebSocketException () internal WebSocketException ()
@ -42,6 +48,11 @@ namespace WebSocketSharp
{ {
} }
internal WebSocketException (Exception innerException)
: this (CloseStatusCode.Abnormal, null, innerException)
{
}
internal WebSocketException (string message) internal WebSocketException (string message)
: this (CloseStatusCode.Abnormal, message, null) : this (CloseStatusCode.Abnormal, message, null)
{ {
@ -57,6 +68,11 @@ namespace WebSocketSharp
{ {
} }
internal WebSocketException (CloseStatusCode code, Exception innerException)
: this (code, null, innerException)
{
}
internal WebSocketException (CloseStatusCode code, string message) internal WebSocketException (CloseStatusCode code, string message)
: this (code, message, null) : this (code, message, null)
{ {
@ -65,7 +81,7 @@ namespace WebSocketSharp
internal WebSocketException (CloseStatusCode code, string message, Exception innerException) internal WebSocketException (CloseStatusCode code, string message, Exception innerException)
: base (message ?? code.GetMessage (), innerException) : base (message ?? code.GetMessage (), innerException)
{ {
Code = code; _code = code;
} }
#endregion #endregion
@ -73,14 +89,16 @@ namespace WebSocketSharp
#region Public Properties #region Public Properties
/// <summary> /// <summary>
/// Gets the status code indicating the cause for the exception. /// Gets the status code indicating the cause of the exception.
/// </summary> /// </summary>
/// <value> /// <value>
/// One of the <see cref="CloseStatusCode"/> enum values, represents the status code indicating /// One of the <see cref="CloseStatusCode"/> enum values, represents the status code
/// the cause for the exception. /// indicating the cause of the exception.
/// </value> /// </value>
public CloseStatusCode Code { public CloseStatusCode Code {
get; private set; get {
return _code;
}
} }
#endregion #endregion