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

A question of Exceptions and loops

I'm just beginning to try to understand Exceptions, so this is probably
a naive question.

Suppose I have a class (A) that has a 'while' loop in a method. Within
this loop the method calls a method of another class B. The method call
is within a 'try'. When the Exception occurs in class B the 'catch'
clause in class A is invoked and handled.

In the 'while' loop, if an Exception has occurred, I'd like the loop to
'continue' rather than merely continue on. Is it legitimate to have the
'continue' in the 'catch'?

Or should I set some indicator in the 'catch' and then use an 'if' to
check the indicator and 'continue'?

Or should I restructure the code (which isn't written yet) completely?

Cheers,

Cliff

--

Have you ever noticed that if something is advertised as 'amusing' or
'hilarious', it usually isn't?
Aug 3 '07 #1
1 1166
Enkidu wrote:
I'm just beginning to try to understand Exceptions, so this is probably
a naive question.

Suppose I have a class (A) that has a 'while' loop in a method. Within
this loop the method calls a method of another class B. The method call
is within a 'try'. When the Exception occurs in class B the 'catch'
clause in class A is invoked and handled.

In the 'while' loop, if an Exception has occurred, I'd like the loop to
'continue' rather than merely continue on. Is it legitimate to have the
'continue' in the 'catch'?

Or should I set some indicator in the 'catch' and then use an 'if' to
check the indicator and 'continue'?

Or should I restructure the code (which isn't written yet) completely?
If you have the catch clause at the bottom of the loop, then
you should not even need continue.

Arne
Aug 3 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

26
by: Zunbeltz Izaola | last post by:
Hi, I've the following problem with try/exception. I've a try block that will raise some exceptions. I want the program to ignore this exceptions completely. Is it possible? Thanks in...
10
by: Olivier Parisy | last post by:
Hi all, I am new to Python (I just finished Guido's tutorial). I was very surprised to learn there that the StopIteration is used to end for loops in a standard iterator setting. I come from...
5
by: John | last post by:
Hi, In my years as a VB programmer, I have settled into this pattern of creating collections classes, with an AddNew() method. AddNew() validates the parameters, instantiates the object, adds...
13
by: Siemel Naran | last post by:
Hi. I posted this question to comp.lang.c++, but am rephrasing it a bit from what I learned and posting to comp.lang.c++.moderated for more insight. So how do I solve my problem? I want it so...
11
by: C# Learner | last post by:
What type of exception should I throw when my code detects that a connection has dropped (i.e. NetworkStream.Read() returns 0)? Should I just throw a SocketException or should I create my own...
3
by: Julia | last post by:
Thanks for all you responses assuming I have a collection of objects which I want to save in a database I wonder if the following is the way to deal with a situation that only some of the...
9
by: Alvin Bruney [MVP] | last post by:
Exceptions must not be used to control program flow. I intend to show that this statement is flawed. In some instances, exceptions may be used to control program flow in ways that can lead to...
10
by: John Nagle | last post by:
Here are three network-related exceptions. These were caught by "except" with no exception type, because none of the more specific exceptions matched. This is what a traceback produced: 1....
1
by: philmarsay | last post by:
I have some code that loops through all contacts in a contact folder (approx 3000), reads some details from each contact and uses that information to perform various functions. However, as the...
5
by: Alex | last post by:
Hi I just want to clear something up in my head with while loops and exceptions. I'm sure this will probably be a no brainer for most. Check this simple pseudo-code out (vb.net): ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.