WebSocketException.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. get; private set;
  46. }
  47. #endregion
  48. }
  49. }