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

Error Recovery Using Exceptions

P: n/a
I wish to implement error recovery using the Exception mechanism
However, I'm not sure I fully appreciate some of the detail in which
this works.

The code that contains a potential error is included in the Try block.
The Catch block is used to catch this exception. The Finally block
will then execute after the Exception has been handled. My questions
are:

1. If the Exception is caught in the Catch block is this referred to
as 'swallowing the exception'

2.If the Exception that is raised is not caught in the Catch block
then will the code in the Finally block still be executed before the
Exception processing transfers to the next higher Catch block.

3. If the Exception is successfully caught in the Catch block will it
be possible to try to recover from the error and do the Try block
again. That is, can I put the Try/Catch block in a loop and then use
my code to determine when to exit from the loop.

Regards

John L
Nov 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
> 1. If the Exception is caught in the Catch block is this referred to
as 'swallowing the exception' No, swallowing is just that - swallowing and pretend it wasn't there
for instance
try
{
bogus code
}
catch
{
}
//contine with code here
2.If the Exception that is raised is not caught in the Catch block
then will the code in the Finally block still be executed before the
Exception processing transfers to the next higher Catch block. Finally blocks are guaranteed to execute. Take that with a grain of salt.
There are instances when the finally blocks don't fire. For most
circumstances, they do.

3. If the Exception is successfully caught in the Catch block will it
be possible to try to recover from the error and do the Try block
again. That is, can I put the Try/Catch block in a loop and then use
my code to determine when to exit from the loop. sure. i do that with regularity.

--
Regards,
Alvin Bruney - ASP.NET MVP

[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
Now available @ www.lulu.com/owc, Amazon.com etc
"gemel" <jo***@glenavon1.demon.co.uk> wrote in message
news:g7********************************@4ax.com...I wish to implement error recovery using the Exception mechanism
However, I'm not sure I fully appreciate some of the detail in which
this works.

The code that contains a potential error is included in the Try block.
The Catch block is used to catch this exception. The Finally block
will then execute after the Exception has been handled. My questions
are:

1. If the Exception is caught in the Catch block is this referred to
as 'swallowing the exception'

2.If the Exception that is raised is not caught in the Catch block
then will the code in the Finally block still be executed before the
Exception processing transfers to the next higher Catch block.

3. If the Exception is successfully caught in the Catch block will it
be possible to try to recover from the error and do the Try block
again. That is, can I put the Try/Catch block in a loop and then use
my code to determine when to exit from the loop.

Regards

John L

Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.