Forums Register Login

throw an exception in catch clause

+Pie Number of slices to send: Send
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?
1
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
 

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!
Today you are you, that is turer than true. There is no one alive who is youer than you! - Seuss. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 232 times.
Similar Threads
Exception handling throw and throws
Exception question
throw exception question
exam watch question
Checked Exceptions are Checked by Compiler to see if they are Handled or Declared
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 09:42:46.