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

where does the throw re-try

P: n/a

Hi

in the example code below, if function A or B throw, and I deal with
it by setting flag to 0, does the code re-execute from the start of
the try line or it resumes from the function that threw and the flag
has no effect?

thanks

for(;;)
{
try
{
if( flag == 0 )
{
x = some_funciton_output( 0 );
}
else if( flag == 1 || flag == -1 ) // reverse
{
x = some_funciton_output( 3 );
}

if( x == 0 )
{
function_A_that_throws();
}
else
{
function_B_that_throws();
}
break;
}
catch (const someException& sde)
{
flag = 0; // could not reverse, then close in the market
}
}
}
Mar 18 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Gary Wessle wrote:
Hi

in the example code below, if function A or B throw, and I deal with
it by setting flag to 0, does the code re-execute from the start of
the try line or it resumes from the function that threw and the flag
has no effect?

thanks

for(;;)
{
try
{
if( flag == 0 )
{
x = some_funciton_output( 0 );
}
else if( flag == 1 || flag == -1 ) // reverse
{
x = some_funciton_output( 3 );
}

if( x == 0 )
{
function_A_that_throws();
}
else
{
function_B_that_throws();
}
break;
}
catch (const someException& sde)
{
flag = 0; // could not reverse, then close in the market
}
}
}
The exception is "caught" at the "catch", flag is set to seto and it
drops into the for(;;) which loops it back to the try and then takes a
different path (possibly) through the nested if's.
Mar 18 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.