When I throw checked exceptions from a method should I just declare the super class of the exceptions in the method signature or all the different types? If I have the follo
The throws
clause is there to convey useful information to the calling method about what might go wrong during invocation of this method. That means that how specific you are will depend on how much information you want to convey; and that will be application-dependent.
For instance, declaring throws Exception
is almost always a bad idea: the information this conveys is just "something might go wrong", which is too vague to be useful. But whether calling classes are going to need perfectly fine-grained information in the throws
clause is something you need to decide by looking at your program. There's no set answer.