Results 1 to 3 of 3
  1. #1
    bobocheez is offline Member
    Join Date
    Aug 2010
    Posts
    28
    Rep Power
    0

    Default 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

  2. #2
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    5

    Default Re: URL error handling

    Catch statements can come one after another...

    Java 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.

  3. #3
    bobocheez is offline Member
    Join Date
    Aug 2010
    Posts
    28
    Rep Power
    0

Similar Threads

  1. Handling Error Messages?
    By DoubleDee in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 12-29-2011, 12:19 PM
  2. Error handling in servlet
    By an24 in forum Java Servlet
    Replies: 2
    Last Post: 12-21-2009, 06:40 PM
  3. [SOLVED] error handling
    By jmHoekst in forum New To Java
    Replies: 9
    Last Post: 07-07-2008, 10:46 PM
  4. Replies: 0
    Last Post: 04-01-2008, 10:17 AM
  5. SQL error handling example
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-12-2008, 09:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •