-
URL error handling
Hi,
I have a giant list of URL's and some connect to a website, and some give errors.
All I have is a throws IOExeption at the top of a method, and a try/catch FileNotFoundException for the URL connection.
The latest error that has come up is UnknownHostException. So my question is, how can a program be made to to handle multiple errors? Nested try/catch or is there another way?
Thanks
-
Re: URL error handling
Catch statements can come one after another...
Code:
try{
someOperation;
}catch(IOException e){ e,printStackTrace()};
catch(Exception e{ e.printStackTrace(); }
Throwing an exception in the head of the function will request the calling function to deal with the exception.
-
Re: URL error handling
Ok that makes sense. Thanks