It is sometimes reasonable for a method to declare that a method throws Exception
. Usually, more specific exceptions are desirable.
For example, the Callable interface has a method that throws Exception:
public interface Callable<V> {
V call() throws Exception;
}
A Throwable
could be either an Exception or an Error. An Error indicates an exception that an application should not try to catch. Any method can throw it, and there's no need to declare it.
From Joshua Bloch's "Effective Java", 2nd ed:
"Always declare checked exceptions individually, and document precisely the conditions under which each is thrown using the Javadoc @throws tag. Don't take the shortcut of declaring that a method throws some superclass of multiple exception classes it can throw. As an extreme example, never declare that a method "throws Exception" or, worse yet, "throws Throwable."
This is almost always the best guideline, with a few exceptions to Bloch's absolute prohibition against "throws Exception."