473,414 Members | 1,636 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,414 software developers and data experts.

where does the throw re-try


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
1 1372
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: BStorm | last post by:
I ran into a maddening bug that I finally tracked down to Microsoft's Data Access Blocks. It is in the SQL Helper UpdateDataSet method as follows: Microsoft Code: #region UpdateDataset public...
2
by: CoolPint | last post by:
Standard exception classes in C++ have what() which returns const char * and they have constructors accepting string. Where is that string created and when is the string destroyed? In the...
3
by: Pierre Rouleau | last post by:
The std::exception class defined in the Standard C++ <exception> header specifies that the constructors could throw any exception becuase they do not have a throw() specification. Why is that? ...
2
by: SammyBar | last post by:
Hi, I'm trying to bind a custom collection class to a data grid, following the guidelines from the article http://msdn.microsoft.com/msdnmag/issues/05/08/CollectionsandDataBinding/default.aspx....
0
by: Bijay Kumar | last post by:
Hi Guys, I was going through the source code of Object class (Object.cs in rotor). What I found is Equals() implemented as follows: public extern virtual bool Equals(Object obj); What...
2
by: felecha | last post by:
I learned about Exceptions in School, and now that I'm building my first real application on the job, I'm going through it trying to analyze it for all possible Exceptions so I can handle them...
10
by: Paul Cheetham | last post by:
Hi, I am developing an application that needs to store some machine-specific settings. The application is going to be published on the network in order to keep the clients on the latest version....
14
by: Anoop | last post by:
Hi, I am new to this newsgroup and need help in the following questions. 1. I am workin' on a GUI application. Does C# provides Layout Managers the way Java does to design GUI? I know that it...
2
by: deepak | last post by:
the code goes some thing like this try { some statements; } catch(Exception ex) { throw; }
6
by: William | last post by:
for example, I have a global object: extern Object myobj; Can gcc get this object by using string "myobj" at runtime?? I know C++ rtti doesnt support this, but I dont know if gcc can , ...
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.