This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Rethrow an exception 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 "Rethrow an exception " Watch "Rethrow an exception " New topic

Rethrow an exception

Yan Bai
Ranch Hand

Joined: Jul 21, 2002
Posts: 125

I thought that at run time, 'First Throw' should be caught by the 2nd catch and never displayed. while 'Second Throw' hasn't been caught, so it will be printed out in the Exception message. But the output is:

Exception in thread 'main' java.lang.Exception: 'First Throw' at ...

why it's 'First Throw'?

SCJP 1.4
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
The scope of the try statement doesn't include the catch or finally clauses.

Ron Newman - SCJP 1.2 (100%, 7 August 2002)
Keen Chen
Ranch Hand

Joined: Nov 12, 2002
Posts: 47
certainly should be the first throw
when u rethrow a exception in a catch , the re-thrown exception can't be caught by the same level catch blocks

SCJP 1.4 100% @ Peking, China <br />~~~~~~~~~~~~~~~~~~~~~<br />但使龙城飞将在, 不教胡马度阴山!
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Rethrow an exception
It's not a secret anymore!