Flow Control with Exception Handling
I'm using exception handling to catch errors, but cannot figure out how to prevent the code after the exception from executing. Example:
try
Statement 1
catch
Error handling for Statement 1
Statement 2
Statement 3
If there is an error with Statement 1 (in this case a null value in a text box), I don't want Statements 2 & 3 to execute since they rely on a valid value. Also Statements 2 & 3 deserve their own try...catch statements. So, I am left with a hugely nested set of try...catches to handle flow control.
I know this is not correct. How should I handle it?
Thanks,
Scott
chirag patelPosted May 17, 2007, 3:26 PM
if u have:
try{
sttement1;
}
catch
{
statement2;
}
statement3;
statement4;
u can do:
int c = 0;
try{
sttement1;
}
catch
{
statement2;
c++;
}
if(c!=0)
{
statement3;
statement4;
}
i think this will solve u r problem.
letme know
regards
chirag
Manoj KumarPosted May 17, 2007, 1:45 PM