How to find out the more specific error situations like whether the error is because of FileNotFoundException , or EOFExceptionor No Internet Access etc….
below is the code that i am using to access the internet and i am getting the IOException and I know this is due to not having permission to access internet.. but how I want to know for SURE that whether this error related with file, or eof or permission related….
below is my code and catching all the exception but none will give me a specific situation exception.
try {
HttpGet request = new HttpGet(MyConstants.URL);
HttpResponse response = null;
response = httpClient.execute(request);
//HttpResponse httpResponse = httpClient.execute(request);
HttpEntity httpEntity = response.getEntity();
xmlList = EntityUtils.toString(httpEntity);
}
catch (MalformedURLException e) {
xmlList = "URL: is a malformed URL";
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
xmlList = "URL: UnsupportedEncodingException";
} catch (ClientProtocolException e) {
e.printStackTrace();
xmlList = "URL: ClientProtocolException";
} catch (SocketTimeoutException e) {
e.printStackTrace();
xmlList = "URL: SocketTimeoutException";
} catch (ConnectTimeoutException e) {
e.printStackTrace();
xmlList = "URL: ConnectTimeoutException";
} catch (IOException e) {
xmlList = "URL: IOException";
e.printStackTrace();
}
Catch it!
There is no such exception as ‘No Internet Access’.