Bug #572
Improve Exception choiche for Client class in Java OCA.
Status: | Closed | Start date: | 04/11/2011 | |
---|---|---|---|---|
Priority: | Normal | Due date: | ||
Assignee: | Carlos Martín | % Done: | 0% | |
Category: | Client API & Library | |||
Target version: | Release 3.0 | |||
Resolution: | fixed | Pull request: | ||
Affected Versions: |
Description
Peeking in the code, I discovered that the Client class throws it when
it does not find two mandatory resources, the $ONE_AUTH file and the
SHA-1 algorithm.
In my (not so) humble opinion, the use of the raw Exception is not
meaningful enought, the use of a OneSetupException would have add NO
testing or correctness complication and could be more useful for the
coder.
Furthermore, I think these are Errors, not Exceptions since you have
no way to recover from one with a try/catch, you have to stop the VM,
correct the setup and restart.
I attach a modified version that uses an Error subclass named OpenNebulaConfigurationError. A long name, but nobody else should write it :).
BTW, putting in the Error I discovered that IOExceptions caused by an unreadable ONE_AUTH where not handled and slipped up as normal Exceptions.
If the OpenNebula team wants, may change the superclass and the name of OpenNebulaConfigurationError, but I would like to know it soon since I am working on some OVF aware OCCI interface for the Venus-C project. Thank you,
Associated revisions
Bug #572: Java OCA, better choice of Exceptions. Thanks to Gian Uberto Lauri <saint@eng.it>
History
#1 Updated by Gian Uberto Lauri about 10 years ago
- File OpenNebulaConfigurationError.java added
I realized that Error does not extend Exception but Throwable. I switched to RuntimeException because you should not write a catch block for OpenNebulaConfigurationError (it is an Error in disguise), but it does not break legacy code. Both versions are interchangeable.
#2 Updated by Ruben S. Montero about 10 years ago
- Target version changed from Release 2.2 to Release 3.0
This is initially scheduled for 2.4
#3 Updated by Carlos Martín almost 10 years ago
- Status changed from New to Closed
- Resolution set to fixed