Exception handling question

S

serge calderara

Dear all,

How can I handle correctly cascading exception?

I generally use to catch exception ib all my function.
This to identify each type the correct place that the
exception occurs. What could happen is that if an
exception occurs inside a function that call others
function, it happend that I could get a never ending loop
of exception routine calling other exception routines.

In case I have a function name Func1 that call inside
Func2,func3,func4,....

How to coreectly exit from function 1 incase an exception
occurs in Funct2, 3 or 4....? In other words how up
cascading can be handle.

fun3 shows its own exception, and funct1 catch exception
of function3.

thanks for your prompt answer
regards
 
E

Eric Gunnerson [MS]

Serge,

If I understand your question, you're asking how do you get exceptions to
propagate.

The runtime has built-in support to handle moving exceptions from a called
function to a calling function. It will keep doing this until a function
either catches the exception or it hits the top function of the program. My
advice is only to catch exceptions if you have a specific recovery in mind,
such as asking the user for a new filename if they enter a bad one.

Hope that helps.

--
Eric Gunnerson

Visit the C# product team at http://www.csharp.net
Eric's blog is at http://blogs.gotdotnet.com/ericgu/

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top