By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,064 Members | 1,524 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,064 IT Pros & Developers. It's quick & easy.

exceptions in finally

P: n/a
Hi all,
If there is an exception inside the finally part of the try block, then
the original exception will be lost. Other than making sure the finally code
does not throw any exceptions and/or putting a try-catch (and ignore
exceptions) block around the code in finally, is there any better way to
handle this situation?
TIA
Sankar Nemani
Nov 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Sankar:

Finally blocks should be used for cleanup code and nothing 'risky' should be
done in them. There are so many different things that can gro wrong in an
app it's hard to answer the question in totally general terms, but as a rule
of thumb, trap only exceptions that you are planning on dealing with
specifically (System.Exception == PureEvil unless it's at the root of the
app) and if you trap specific exceptions , then you can rest assured that
you won't throw additional ones in the finally block.

HTH

Bill
"Sankar Nemani" <sn*****@nospamlumedx.com> wrote in message
news:eg**************@TK2MSFTNGP11.phx.gbl...
Hi all,
If there is an exception inside the finally part of the try block, then the original exception will be lost. Other than making sure the finally code does not throw any exceptions and/or putting a try-catch (and ignore
exceptions) block around the code in finally, is there any better way to
handle this situation?
TIA
Sankar Nemani

Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.