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.

Full Threads Newest First

Showing messages 1 through 3 of 3.

  • 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.
    • You *CAN* ignore checked exceptions in Java
      2003-05-14 14:25:23  anonymous2 [View]

      Sorry, I don't write Java (yet).
      But either one wants an implicit exception handler to percolate the exception (fi the ILE language compilers on the IBM AS/400) and thus one has to 'steal back' the exception one does want to catch or one has (must) to tell the compiler that one likes to pass the exception up. Either way you'll need to specify what you want.
      If compilers were smart enough to read the mind there was no need to do any coding at all. (Oops, just told you my favorite programming language)

      Of course, maybe this isn't a philosophical thread.
  • 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.