Let's say you have some method declaring throwing an unchecked exception
EDIT: let's say it's not you who designed this method, but authors of a very respectable framework (Spring, aekhm!), you're just calling it
void someMethod() throws UncheckedException;
My first question is:
- Is there any reason other than clarity for declaring that unchecked exception in the throws clause?
Let's say you have another method that's calling someMethod
void someOtherMethod() {
someMethod()
}
My second question is:
- What would be the best practice of deciding whether to declare throwing the
UncheckedException
in thesomeOtherMethod
?
Just a little background:
Spring framework's exception are based on unchecked exceptions. So for example some methods are throwing (and declaring it in the throws
) DataAccessException. If my code is using these calls, should it or should it not declare throwing these exceptions? And why?