Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

exceptions

 
mrudul joshi
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How should we catch the exception that is rethrown from the catch block itself?if we are to provide another catch block for this exception, where should we write the catch block?or should the exception be handled in the same catch block from which it is thrown?
please clarify.
thanks
 
Anupam Sinha
Ranch Hand
Posts: 1090
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mrudul
In case you think the catch block would throw any exception you can catch it in another catch block. Just put an extra try catch around it.
 
Ana Abrantes
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know if I understood your doubt correctly, but there's my answer:
If you're throwing an exception it generally means you want another method to handle it, so there's no obligation to catch it since you declare a throws clause in the method's signature.
See an example:

or

or
 
mrudul joshi
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the replies.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic