473,378 Members | 1,541 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Undestanding Exception Processing

I am fairly comfortable with much of the .NET Exception mechanism, but
I'm a bit unsure of some areas.

1. When an exception occurs and the exception is not caught then
Exception processing will continue at the next Catch block up the
stack. When this happens will the 'Finally' block of the original
'Try/Catch' be executed?

2. If I wish to recover from the error that caused the Exception can I
put the Try/Catch in a loop so that I can retry the statement that
caused the error?

3. Can I mix Exception handling with the traditional On Error Resume
statements to allow me to do graceful recovery?
Regards

John L
Nov 17 '05 #1
3 1713
Answer 1: Following is the flow trace when an exception hasn't been
serviced in its original try/catch block and continue at the next catch
block.

i. Finally of original try/catch
(Optional) Finally of other try/catch blocks (up the stack) where
exception was not serviced
ii. Catch block where exception was serviced.
iii. Finally of the catch where exception was serviced.

Answer 2: Try/catch can not be looped unless you use labels (see: goto
statement). I personally think that it is not a good idea to loop a
try/catch. because if a statement fails once, it'll always fail to pass
try/catch.

I don't have much Idea about your third question.
HTH. Cheers :)

Maqsood Ahmed [MCP,C#]
Kolachi Advanced Technologies
http://www.kolachi.net

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #2
Thank you very much for responding to my post. With regard to the
looping of the try, this is what I need to do:

Say I am validating input from a textbox and I use a try block to help
me. If an Exception occurs then I would like to allow a retry of the
input again. How can I go back retry the code that has just 'failed'
Regards

John L
On Tue, 26 Apr 2005 05:14:21 -0700, Maqsood Ahmed
<ma***********@gawab.com> wrote:
Answer 1: Following is the flow trace when an exception hasn't been
serviced in its original try/catch block and continue at the next catch
block.

i. Finally of original try/catch
(Optional) Finally of other try/catch blocks (up the stack) where
exception was not serviced
ii. Catch block where exception was serviced.
iii. Finally of the catch where exception was serviced.

Answer 2: Try/catch can not be looped unless you use labels (see: goto
statement). I personally think that it is not a good idea to loop a
try/catch. because if a statement fails once, it'll always fail to pass
try/catch.

I don't have much Idea about your third question.
HTH. Cheers :)

Maqsood Ahmed [MCP,C#]
Kolachi Advanced Technologies
http://www.kolachi.net

*** Sent via Developersdex http://www.developersdex.com ***


Nov 17 '05 #3
Hello,
I prefer to write another method for validing any data. Show a pop up
message when an exception occurs and return from the validation method.
Use bool to show success or failure of the validation.
Using this architecture you can always call this method to call the
try/catch again and again on retries for validation of the input text.

HTH. Cheers.

Maqsood Ahmed [MCP,C#]
Kolachi Advanced Technologies
http://www.kolachi.net

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Scott J. Chlebove | last post by:
I am running a PL/SQL module in which I do the following.... BEGIN DBMS_OUTPUT.enable(1000000); -- Open file for writing. OutfileHandler1 := UTL_FILE.FOPEN(wc_file_path, wc_output_file1,...
7
by: Jacek Dziedzic | last post by:
Hi! I'm trying to make friends with exceptions. I think I'm doing well, there is one thing that bothers me, however. If an object is declared within a try block, it gets destroyed on exception,...
3
by: Professor Frink | last post by:
First off, I apologize if this gets long. I'm simply trying to give you all enough information to help me out. I'm writing (almost finished, actually), my first VB.Net application. It's a forms...
44
by: craig | last post by:
I am wondering if there are some best practices for determining a strategy for using try/catch blocks within an application. My current thoughts are: 1. The code the initiates any high-level...
4
by: Craig831 | last post by:
First off, I apologize if this gets long. I'm simply trying to give you all enough information to help me out. I'm writing (almost finished, actually), my first VB.Net application. It's a forms...
1
by: metsys | last post by:
We have an ASP.NET 2.0 (C#) application that is divided into multiple layers. The multiple layers come from having a web project and 2 different class library projects in the same solution. I'm...
2
by: Petr Jakes | last post by:
I am a little bit confused by all possibilities for exceptions handling in Python (probably because I am not skilled enough??) I did try to search trough this list and reading Python tutorial about...
14
by: Rex | last post by:
Re: Looking for Tips/Writeup on overall approach to Exception Processing Hi All - I am fairly new to C# and am wondering how to best implement (overall) Exception Processing within my...
7
by: Brendon Costa | last post by:
Hi all, I have a small python project i am working on. Basically i always have two threads. A "Read" thread that sits in a loop reading a line at a time from some input (Usually stdin) and then...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.