I am using library which issues HTTP request by calling
java.net.URL.getInputStream()
In the small portion of requests, it throws IOException
. Message of this exception indicates that HTTP Error 500 has been processed.
I am concerned if I am able to get connection error stream from exception. I know that 500 indicates error in the requested API, but I would like to get as many information about error as possible.
I know that
java.net.URL.getInputStream()
is shorthand for
java.net.URL.getConnection().getInputStream()
and I could get error stream from java.net.HttpUrlConnection
- but as library does this, it is not available for me.
The library is google geocoder for java, maven artifact
<dependency>
<groupId>com.google.code.geocoder-java</groupId>
<artifactId>geocoder-java</artifactId>
<version>0.16</version>
</dependency>
This is different from question that this question has been marked as duplicate of, as this is not about handling error from java.net.HttpConnection
in general, but only in specific case where all I can do is only catching exception - if it is possible to obtain error stream from exception somehow.