where does the throw re-try

G

Gary Wessle

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
}
}
}
 
G

Gianni Mariani

Gary said:
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.
 

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

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top