Article:
  What I Hate About Your Programming Language
Subject:   You *CAN* ignore checked exceptions in Java
Date:   2003-05-14 06:58:07
From:   anonymous2
Don't program much in Java, do you? To "ignore" an exception thrown at you, just declare your method thusly:


public void myMethod () throws Exception {
}


With whatever return type, access control, name, and parameter list you need. Saying "throws Exception" ignores the entire group of checked exceptions. You can percolate this all the way up to the main method, which if it throws an exception, causes the default handler (dump the stack to stderr and terminate the thread) to spring into action.

Main Topics Oldest First

Showing messages 1 through 2 of 2.

  • You *CAN* ignore checked exceptions in Java
    2004-03-30 07:11:18  typo [View]

    While this is kind of true, you have to deal with the exception somewhere, unless you do something like

    public static void main (String[]agrgs) throws Exception {...}

    Then that kind of defeates the good things that try blocks do.


  • You *CAN* ignore checked exceptions in Java
    2003-05-14 11:56:07  anonymous2 [View]

    I think the point is that you're not "ignoring" exceptions when you have to include the phrase "throws Exception" in every method up the stack.