• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Rethrow an exception

 
Yan Bai
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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'?
 
Ron Newman
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The scope of the try statement doesn't include the catch or finally clauses.
 
Keen Chen
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic