Why do some Java
methods throw exceptions that are subclasses of another exception that they also throw?
One example is org.apache.commons.httpclient.HttpClient
.executeMethod(HttpMethod method). It throws the HttpException
, which is a subclass of the IOException
, which it also throws. Syntactically, it would have been okay to just throw the more general (in this case, IO) exception and to omit the HttpException from the throws
clause.
Does listing more specific exceptions in the throws clause of a method beside a more general one accomplish anything?