aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes On Exception Handling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "On Exception Handling" Watch "On Exception Handling" New topic
Author

On Exception Handling

Karthik Balasubramanian
Ranch Hand

Joined: Dec 13, 2002
Posts: 43
Can we throw an exception from "Catch" and "Finally" block?
Thanks,
Karthik
Shiva Mantri
Greenhorn

Joined: Dec 30, 2002
Posts: 19
yes you can, but you will lose the exception information thrown from try clause, unless you log the exception information.

JLS11.3 Handling of an exception
If a try or catch block in a try-finally or try-catch-finally statement completes abruptly, then the finally clause is executed during propagation of the exception, even if no matching catch clause is ultimately found. If a finally clause is executed because of abrupt completion of a try block and the finally clause itself completes abruptly, then the reason for the abrupt completion of the try block is discarded and the new reason for abrupt completion is propagated from there.

[ January 28, 2003: Message edited by: Shiva Mantri ]
Sarma Lolla
Ranch Hand

Joined: Oct 21, 2002
Posts: 203
Although in real world projects you rarely use the finally block, it is very common to catch one exception and throw another exception from the catch clause.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: On Exception Handling