0

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.

Martin Hlavňa
  • 648
  • 7
  • 20
  • What library are you using? We cannot help if we don't know what lib you use. – cello Oct 31 '17 at 08:13
  • I added library to question, but I think this is more relevant to HttpUrlConnection than library itself. – Martin Hlavňa Oct 31 '17 at 08:33
  • @cello He is using `java.net.URL`, `java.net.HttpURLConnection`, `java.io.InputStream`, etc. All this is immediately apparent from the original question. Don't ask pointless questions here. – user207421 Oct 31 '17 at 09:15
  • Hello @EJP , I think this is not duplicate question - I have edited it to give more details about what I would like to handle. – Martin Hlavňa Oct 31 '17 at 11:45
  • @EJP ...and this is why I thought the library is important, as the OP is restricted by the library. It was probably confusing as the OP already did an analysis of the library's source code, and there it could be solved easily, but maybe there is a way to solve it without modifying the libraries source code. – cello Oct 31 '17 at 12:16

0 Answers0