Note that there are some explanatory texts on larger screens.

plurals
  1. POIOException stops application although the exception was handled
    text
    copied!<p>Sometimes when I open a stream:</p> <pre><code>stream = url.openStream(); BufferedReader buffReader = new BufferedReader(new InputStreamReader(stream)); </code></pre> <p>I get the following exception:</p> <pre><code>java.io.IOException: Server returned HTTP response code: 500 for URL: https://... </code></pre> <p>and my applications ends although I'm handling the exception with:</p> <pre><code>catch (IOException ioe) { ioe.printStackTrace(); } </code></pre> <p>could someone please explain to me why the catch block wasn't entering although it's an IOEcxeption?</p> <p>thx</p> <p>Edit (additional code ;-)</p> <pre><code>private String request(URL url) { InputStream stream = null; String line, response = new String(); try { stream = url.openStream(); BufferedReader buffReader = new BufferedReader(new InputStreamReader(stream)); while ((line = buffReader.readLine()) != null) response += line; } catch (MalformedURLException mue) { mue.printStackTrace(); } catch (HTTPException httpexc) { httpexc.printStackTrace(); } catch (IOException ioe) { ioe.printStackTrace(); } finally { try { stream.close(); } catch (IOException ioe) { ioe.printStackTrace(); } } return response; } </code></pre> <p>I run this code very often in my application and just sometimes I get the mentioned exception.</p> <p>Here's a part of the stacktrace:</p> <pre><code>java.io.IOException: Server returned HTTP response code: 500 for URL: ... at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source) at java.net.URL.openStream(Unknown Source) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload