Exception Type

+1 vote
asked Jun 16, 2015 by ndsinfodeveloper (290 points)

Can we get List of Exception and Eception Type and number so we can distinguish them and handle them

1 Answer

0 votes
answered Jun 16, 2015 by Tomas Knopp (58,890 points)
edited Dec 22, 2020 by Lukas Pokorny

Exceptions in Rebex components:

Standard exceptions are raised when appropriate:
- ArgumentException (bad argument provided)
- InvalidOperationException (you called a method when you shouldn't)
- ObjectDisposedException (the client object is disposed)

In other situations, Rebex component-dependent exceptions are raised instead:

Rebex SFTP:
- SftpException for SFTP

Rebex FTP/SSL:
- FtpException for FTP
- TlsException for FTP/SSL

Rebex Secure Mail:
- ImapException for IMAP
- Pop3Exception for POP3
- SmtpException for SMTP

and others for other components (TerminalException, SshException, TelnetException, WebSocketException ...)

These exceptions usually feature Status property that makes it possible to determine the error category. For example, status of ProtocolError indicates server-side errors, and in this case, there is usually another property you can check for more protocol-dependent information, such as:
- SftpException.Code in Rebex SFTP
- FtpException.Response in Rebex FTP
- ImapException.Response in Rebex IMAP

All the protocol-dependent exceptions inherit from NetworkSessionException, which might be convenient when working with multiple different Rebex classes.

...