SshConnectionException.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System;
  2. using Renci.SshNet.Messages.Transport;
  3. namespace Renci.SshNet.Common
  4. {
  5. /// <summary>
  6. /// The exception that is thrown when connection was terminated.
  7. /// </summary>
  8. public partial class SshConnectionException : SshException
  9. {
  10. /// <summary>
  11. /// Gets the disconnect reason if provided by the server or client. Otherwise None.
  12. /// </summary>
  13. public DisconnectReason DisconnectReason { get; private set; }
  14. /// <summary>
  15. /// Initializes a new instance of the <see cref="SshConnectionException"/> class.
  16. /// </summary>
  17. public SshConnectionException()
  18. {
  19. }
  20. /// <summary>
  21. /// Initializes a new instance of the <see cref="SshConnectionException"/> class.
  22. /// </summary>
  23. /// <param name="message">The message.</param>
  24. public SshConnectionException(string message)
  25. : base(message)
  26. {
  27. DisconnectReason = DisconnectReason.None;
  28. }
  29. /// <summary>
  30. /// Initializes a new instance of the <see cref="SshConnectionException"/> class.
  31. /// </summary>
  32. /// <param name="message">The message.</param>
  33. /// <param name="disconnectReasonCode">The disconnect reason code.</param>
  34. public SshConnectionException(string message, DisconnectReason disconnectReasonCode)
  35. : base(message)
  36. {
  37. DisconnectReason = disconnectReasonCode;
  38. }
  39. /// <summary>
  40. /// Initializes a new instance of the <see cref="SshConnectionException"/> class.
  41. /// </summary>
  42. /// <param name="message">The message.</param>
  43. /// <param name="disconnectReasonCode">The disconnect reason code.</param>
  44. /// <param name="inner">The inner.</param>
  45. public SshConnectionException(string message, DisconnectReason disconnectReasonCode, Exception inner)
  46. : base(message, inner)
  47. {
  48. DisconnectReason = disconnectReasonCode;
  49. }
  50. }
  51. }