2
0

WebSocketException.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using System;
  2. namespace SocketHttpListener
  3. {
  4. /// <summary>
  5. /// The exception that is thrown when a <see cref="WebSocket"/> gets a fatal error.
  6. /// </summary>
  7. public class WebSocketException : Exception
  8. {
  9. #region Internal Constructors
  10. internal WebSocketException()
  11. : this(CloseStatusCode.Abnormal, null, null)
  12. {
  13. }
  14. internal WebSocketException(string message)
  15. : this(CloseStatusCode.Abnormal, message, null)
  16. {
  17. }
  18. internal WebSocketException(CloseStatusCode code)
  19. : this(code, null, null)
  20. {
  21. }
  22. internal WebSocketException(string message, Exception innerException)
  23. : this(CloseStatusCode.Abnormal, message, innerException)
  24. {
  25. }
  26. internal WebSocketException(CloseStatusCode code, string message)
  27. : this(code, message, null)
  28. {
  29. }
  30. internal WebSocketException(CloseStatusCode code, string message, Exception innerException)
  31. : base(message ?? code.GetMessage(), innerException)
  32. {
  33. Code = code;
  34. }
  35. #endregion
  36. #region Public Properties
  37. /// <summary>
  38. /// Gets the status code indicating the cause for the exception.
  39. /// </summary>
  40. /// <value>
  41. /// One of the <see cref="CloseStatusCode"/> enum values, represents the status code indicating
  42. /// the cause for the exception.
  43. /// </value>
  44. public CloseStatusCode Code
  45. {
  46. get; private set;
  47. }
  48. #endregion
  49. }
  50. }