• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Rethrowing the same exception

 
Kay Liew
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have been reading the same page for a little more than an hour.

In KB book, page 254, it stated something like "All other catch clauses associated with the same try are ignored and the exception is thrown back to the calling method (the next method down the call stack) If you throw a checked exception from the catch clause, you must also declare that exception.
I have 2 questions.
First how should I fix the following code so that it considered as re-declare again ? I am thinking declaring in LINE # 1 but then what is the point of this sub-chapter? Isn't it trying to show me what is rethrowing the same exception ???



Second, I am not able to follow the author in describing the different between the following codes and the above one. I think the codes presented in the book got to have a reason.



I am hoping someone can give me a more realistic small portion of the codes demonstration.

Thanks,
[ November 06, 2004: Message edited by: Kay Liew ]
 
Mark Patrick
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kay,

You have written the code example wrong. They would never compile.



The snippet in the book that just lists the catch clause does the same thing as the catch clause above. It's in the book to highlight that you can re-throw a caught exception.
 
Kay Liew
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark,

Thank you for the hint. I think you have confirmed with what I read. It made more sense now.

k
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic