ErrorEventArgs.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #region License
  2. /*
  3. * ErrorEventArgs.cs
  4. *
  5. * The MIT License
  6. *
  7. * Copyright (c) 2012-2022 sta.blockhead
  8. *
  9. * Permission is hereby granted, free of charge, to any person obtaining a copy
  10. * of this software and associated documentation files (the "Software"), to deal
  11. * in the Software without restriction, including without limitation the rights
  12. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13. * copies of the Software, and to permit persons to whom the Software is
  14. * furnished to do so, subject to the following conditions:
  15. *
  16. * The above copyright notice and this permission notice shall be included in
  17. * all copies or substantial portions of the Software.
  18. *
  19. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  23. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  25. * THE SOFTWARE.
  26. */
  27. #endregion
  28. #region Contributors
  29. /*
  30. * Contributors:
  31. * - Frank Razenberg <frank@zzattack.org>
  32. */
  33. #endregion
  34. using System;
  35. namespace WebSocketSharp
  36. {
  37. /// <summary>
  38. /// Represents the event data for the <see cref="WebSocket.OnError"/> event.
  39. /// </summary>
  40. /// <remarks>
  41. /// <para>
  42. /// The error event occurs when the <see cref="WebSocket"/> interface
  43. /// gets an error.
  44. /// </para>
  45. /// <para>
  46. /// If you would like to get the error message, you should access
  47. /// the <see cref="ErrorEventArgs.Message"/> property.
  48. /// </para>
  49. /// <para>
  50. /// If the error is due to an exception, you can get it by accessing
  51. /// the <see cref="ErrorEventArgs.Exception"/> property.
  52. /// </para>
  53. /// </remarks>
  54. public class ErrorEventArgs : EventArgs
  55. {
  56. #region Private Fields
  57. private Exception _exception;
  58. private string _message;
  59. #endregion
  60. #region Internal Constructors
  61. internal ErrorEventArgs (string message)
  62. : this (message, null)
  63. {
  64. }
  65. internal ErrorEventArgs (string message, Exception exception)
  66. {
  67. _message = message;
  68. _exception = exception;
  69. }
  70. #endregion
  71. #region Public Properties
  72. /// <summary>
  73. /// Gets the exception that caused the error.
  74. /// </summary>
  75. /// <value>
  76. /// <para>
  77. /// An <see cref="System.Exception"/> instance that represents
  78. /// the cause of the error.
  79. /// </para>
  80. /// <para>
  81. /// <see langword="null"/> if not present.
  82. /// </para>
  83. /// </value>
  84. public Exception Exception {
  85. get {
  86. return _exception;
  87. }
  88. }
  89. /// <summary>
  90. /// Gets the error message.
  91. /// </summary>
  92. /// <value>
  93. /// A <see cref="string"/> that represents the error message.
  94. /// </value>
  95. public string Message {
  96. get {
  97. return _message;
  98. }
  99. }
  100. #endregion
  101. }
  102. }