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)

Exceptions in Rebex components:

standard exceptions
- ArgumentException (bad argument provided)
- InvalidOperationException (you called a method when you shouldn't)
- ObjectDisposedException (the client object is disposed)

Then there are component dependant exceptions, typically one per protocol/component, i.e.

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, ...)

Good news is that all the protocol dependant exceptions iherit from NetworkSessionException so you can catch for this type and make your code easier.

Please note that NeworkSessionException.Status represents the category of error that ocurred. In case the Status is set to ProtocolError, there is usually another property that you can check, and it provides the protocol-dependant error info, like:
- SftpException.Code in Rebex SFTP or
- FtpException.Response in Rebex FTP
- ImapException.Response in Rebex IMAP, etc.