S
Scott Harper
I have a method that does some HTTP posting. Inside that method are calls
that can generate MalformedURLException, ProtocolException,
UnsupportedEncodingException, as well as the more general IOException in it's
own right. The three former exceptions are subclasses of IOException. All of
these are propated up and handled by the calling method.
How do people generally code this? For the throwing method, do you specify
throws MalformedURLException, ProtocolException, UnsupportedEncodingException,
IOException
explicitly? Or just
throws IOException
Seems like the former gives a more clear definition of what the method can
throw, but the latter is certainly more concise.
For the catching method, just a simple
catch (IOException e)
or explicitly catch all of them? I lean toward the simple case since nothing
different will be done to handle any of these exceptions, and the "diagnostic"
part of the exception (message, cause, etc.) will still be available even if
referred to by the super class...
scott
that can generate MalformedURLException, ProtocolException,
UnsupportedEncodingException, as well as the more general IOException in it's
own right. The three former exceptions are subclasses of IOException. All of
these are propated up and handled by the calling method.
How do people generally code this? For the throwing method, do you specify
throws MalformedURLException, ProtocolException, UnsupportedEncodingException,
IOException
explicitly? Or just
throws IOException
Seems like the former gives a more clear definition of what the method can
throw, but the latter is certainly more concise.
For the catching method, just a simple
catch (IOException e)
or explicitly catch all of them? I lean toward the simple case since nothing
different will be done to handle any of these exceptions, and the "diagnostic"
part of the exception (message, cause, etc.) will still be available even if
referred to by the super class...
scott