[jcifs] SmbException Supercedes boolean?

Allen, Michael B (RSCH) Michael_B_Allen at ml.com
Tue Oct 30 10:57:58 EST 2001

> Also - its what the java libraries do...
> mkdir()
>     public abstract boolean mkdir()
>     Creates a directory, the pathname of which is specified by this
>     XFileAccessor object.
> Returns true if the directory could be created; false otherwise.
	This was exactly the original reasoning. However there really is so much
	that can go wrong that there needs to be more feedback.

> Just my religion...
> Besides, does it harm to return boolean?
	Well it doesn't harm anything but if we throw SmbException it becomes
	pointless because the two return mechanisms are mutually exclusive; any
	grounds for returning false would also trigger an exception which means you
	will never get the chance to test for the false condition. IOW these methods
	would always return true. Otherise and SmbException is thrown.

>  It may come a time where its 
> benifical to the code.
	Then what you're suggesting is that _some_ operations not cause an
	exception to be thrown but rather return false. I'd rather not do this because
	it just creates and extra return context (SmbException can be thrown
	_except_ for these operations). That would be ugly.

> Is it not possible to not make a directory/file etc.. and not throw a 
> exception?
	Sure; if the directory was successfully created.

> What about isDirectory() ???
> That *must* return boolean and possibly throw an exception?
	Yes, isDirectory and isFile have the additional context mentioned above so
	they will continue to return boolean. But the additional context an obvious
	one. These methods will throw an SmbException if, for example, the target was
	not found.


More information about the jcifs mailing list