This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Whats the point? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Whats the point?" Watch "Whats the point?" New topic
Author

Whats the point?

Amit Batra
Ranch Hand

Joined: Mar 04, 2006
Posts: 361
Whats the point of rethrowing an exception from a catch block when it cant be handled by other catch blocks. And if the exception rebounds back to the calling method, isnt a JVM shutdown then inevitable?
Theodore Casser
Ranch Hand

Joined: Mar 14, 2001
Posts: 1902

If the exception rebounds back to the calling method, it isn't inevitable that you're going to have a JVM shutdown - there are times when I'm programming that the "proper" response is to kick the message back a step to let the calling method deal with the matter. For instance, when I'm writing a utility class for large portions of an app, I'm going to want to handle any issues that arrise in different ways depending on what's happening at the moment when it was called, rather than having a single standard method. Perhaps in one spot it's appropriate to stop processing, while at others it's more appropriate to simply flag a warning and continue.

As for the point of rethrowing the exception, again, sometimes there's other things you're going to want to do with the thrown exception, after initially dealing with it. (At my office, for instance, we sometimes wrap our exceptions in another exception as we throw back to the calling method, to have a standard message appear for our users, while allowing us to see what was going on.)


Theodore Jonathan Casser
SCJP/SCSNI/SCBCD/SCWCD/SCDJWS/SCMAD/SCEA/MCTS/MCPD... and so many more letters than you can shake a stick at!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Whats the point?
 
Similar Threads
signed applet issue
"extra" Exception catching ?
H1-B Nightmare
SCWCD online books and material needed
Help needed on Reflection