• Post Reply Bookmark Topic Watch Topic
  • New Topic

throw an exception in catch clause  RSS feed

 
Duc Ta
Ranch Hand
Posts: 46
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What would happen when I throw an exception like the code below:


It means that I must handle the exception that I have thrown in catch clause in other methods, which call to doStuff() method?
 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That is equivalent to this code:-Yes, you must handle that exception elsewhere, assuming it is a checked type.
I would suggest you go through the Java™ Tutorials, paying particular attention to the section about throwing exceptions. You would usually throw a different sort of exception, probably chaining it to the original exception.
 
Duc Ta
Ranch Hand
Posts: 46
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:That is equivalent to this code:-Yes, you must handle that exception elsewhere, assuming it is a checked type.
I would suggest you go through the Java™ Tutorials, paying particular attention to the section about throwing exceptions. You would usually throw a different sort of exception, probably chaining it to the original exception.


Many thanks Mr Campbell Ritchie!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!