Exception specification for Rebex API

+1 vote
asked Jul 28, 2010 by _FRED_ (640 points)
edited Aug 10, 2010

Can you add to documentation a specification about exceptions, that methods in your API can throw?

Your exceptions, like SftpException, SshException, ProxySocketException, does not have an one base (like "RebexException") class and this is OK, but writing code is hard: when unknown, what kind of exceptions can be thrown.

1 Answer

+1 vote
answered Jul 29, 2010 by Lukas Pokorny (126,870 points)
edited Jul 29, 2010
Best answer

We do plan to document this in one of the next releases, we are aware that a clear specification would be very helpful.

Anyway, in Rebex SFTP, when working with the main Sftp class, you can generally catch SftpException only - SshExceptions and ProxySocketExceptions should be re-thrown as SftpException with an appropriate Status and an InnerException set to the original exception.

Other than that, methods and properties of all classes can throw ArgumentException and InvalidOperation, but these usually indicate that something is wrong with your code (or our code) and should not be handled unless for logging or error reporting purposes.

The SshPrivateKey class methods might throw CryptographicException when a cryptography-related error occurs.

commented Jul 29, 2010 by _FRED_ (640 points)
Thanks, exceptions really wrapped and this is good. This is my mistake: I was not careful. I thought that when working with Sftp, the ProxySocketException can be handled.