[jcifs] SmbException Supercedes boolean?

Rob Wygand rob at wygand.com
Tue Oct 30 09:22:10 EST 2001

Christopher R. Hertel wrote:

> My gut is also to return boolean and provide an async mechanism for
> determining the cause of the failure.  We are dealing with an object,
> which has some degree of persistence, so it should be possible to retain the
> last error code, no?  Instead of using a handler, you would follow a failed
> request with a call to the object requesting the error value.  The only
> problem I see with this is that it could get very messed up in a
> multi-threaded environment (which is why a handler would be useful).

Chris, I totally agree with you here. When I first encountered jCIFS I 
thought it should throw exceptions... but in the last few months I've 
decided that might not be the best route. Exceptions are for exceptional 
cases, and using them to retrieve an error code seems like overkill.

Also, having recently written an API that does throw exceptions I can 
say that it's quite messy-looking code. Trys and Catches everywhere, ugh.

The 'last error code' would be all but useless in a multi-threaded 
environment, as you said. Another approach, instead of a handler, would 
be to return an object instead of a boolean. That object could then be 
queried for error class and error code.

> I like the idea of sticking as close as possible to existing interfaces.

I'd much prefer to stay as close to the existing APIs and well (this is 
also a bit of an about-face for me...), but I also think the need that 
changing the API to throw them was addressing is critical.

Very interested in hearing Mike's input...


More information about the jcifs mailing list