I'm using Java 11 http-client (java.net.http).
The send() method declares these exceptions:
@throws IOException
@throws InterruptedException
@throws IllegalArgumentException
@throws SecurityException
I am interested in catching exceptions caused by timeout.
I thought the best way of doing it is by catching
HttpTimeoutException (extends IOException)
However, I sometimes see that when a timeout occurs the exception that is thrown is:
java.io.IOException: Connection timed out
Now I wonder:
- Why does the more general exception thrown?
- How should the catch be written to make sure all possible time-out related exceptions are caught?