On 26.4.12 17:22, Angela Schreiber wrote:
hi all
i would like to start the discussion again regarding
exception handling in oak-core and the api.
the current situation is as follows:
- runtimeException every here and there
- invalidArgumentException
- unspecific commitFailedExceptions
now that we have quite some JCR functionality present
those exceptions are pretty cumbersome and result in a
lot of test-case failure.
my preference was to just throw the jcr-exceptions where
ever this was appropriate and unambiguous. for example
namespaceexception, versionexception, constraintviolation...
+1 if the thrower of the exception is pretty sure that no one upstream
in the call chain would be forced to catch the exception without knowing
what to do with it. Like in the case where you have to implement an
interface where you are not allowed to throw an exception which might be
thrown by some of the methods you are calling.
In the other case why not throw an exception which extends from
RuntimeException and carries an checked exception? Something along the
lines of:
public class OakException extends RuntimeException {
private final RepositoryException repositoryException;
[...]
public void throwRepositoryException() throws RepositoryException {
throw repositoryException;
}
}
Since we are having these wrappers anyway we can unwrap these exceptions
there and throw the original one.
Michael
kind regards
angela