In the catch block, you can re-throw the catched exception again or re-throw a new checked exception that is declared in throws clause of your method header. If an exception handler re-throws an exception (throw in a catch block), same rules apply. Either you need to have a try/catch within the catch or specify the entire method as throwing the exception that is being re-thrown in the catch block. Catch blocks at the same level will not handle the exceptions thrown in a catch block it needs its own handlers.
Joined: Sep 11, 2005
You can just throw a new exception in the catch block that's not declared in the method header.
Michael's first statement sounds correct to me. Owen's, too...
Only that exceptions are CAUGHT, not catched. And NEW exceptions are THROWN, not re-thrown.
Michael's third statement seems problematic. You can throw a new exception in a catch-block, but it still would have to be a subclass of the exception already declared in the header. If it were not, it would have to be declared or be thrown inside of a nested try-catch-block. It's simple: Catch or declare. [ July 09, 2006: Message edited by: Douglas Chorpita ]