473,796 Members | 2,376 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

8 years of C++ Exception Handling

Meanwhile there are at least 8 years that compilers exist,
which provide a working implementation of C++ Exception Handling.
Has anything changed meanwhile?
From my point of view nothing has changed
-- people are still using a coding style, which I call
pre-C++-Exception-Handling.
Is this different in your experience?
What is your experience regarding this subject?
I think that a C++ IOstream lib, which is by standard free of exceptions
certainly did not help here.
Jul 22 '05
28 2262
E. Robert Tisdale wrote:
Jorge Rivera wrote:
Any language feature can be abused.
I still prefer them over returning error code values.


Why return an error code?
Why not return a complete *exception* object
which includes *all* of the information required
to handle the exception in an enclosing scope?


To have an intelligent discussion here, I think we need to categorize
the different conditions that are candidates for management by exception
and then compare them to alternative ways that they can be handled.

.... I'll let someone else take a crack at it, I'm sleepy.

Jul 22 '05 #11


Jorge Rivera wrote:
lilburne wrote:

After that everything else failing is a bug/algorithm failure, and
outside the scope of legitimate handling by exceptions.

I disagree to this last statement. You can use exceptions to avoid (or
try very hard at least) people from ignoring errors. I mean, how often
have you seen code or written that ignore return status? You just can't
do that with exceptions, or you have to pay for it...

Exceptions, if designed and used properly, can help in producing more
robust code. Let { if(ret == -1) } code for C programmers....


What is an error? Other than user input problems, hardware failure, etc
I wouldn't accept that there are any errors that aren't bugs.

In your example how do *you* know that failure 'if(ret == -1)' wasn't what
I was coding for? By throwing an exception *you* have dictated that *my*
code
does its processing inside a catch block, which just seems plain odd.

Additionally even if I write *my* code such that your code never throws an
exception *you* still force me to pay the overhead of stack unwinding.
Jul 22 '05 #12

"Gianni Mariani" <gi*******@mari ani.ws> wrote in message
news:bu******** @dispatch.conce ntric.net...
E. Robert Tisdale wrote:

My guess is that you *throw* exceptions from void functions,
that you *throw* exceptions when you detect programming errors,
that you write code to detect exceptions that should never occur and that you *throw* exceptions even when the exception could be handled in the scope where it was first detected.


What you wrote is ambiguous. Are the points you wrote above
reccomendations or attempt at ESP ? There are a things you said

there that throw alarm bells.


Shouldn't that be *throw* alarm bells? ;-)

Jonathan
Jul 22 '05 #13
Gianni Mariani wrote:
What you wrote is ambiguous.
Are the points you wrote above recommendations or attempt at ESP?
There are a things you said there that *throw* alarm bells.


I can't help you with the ringing in your ears.
You need to see your doctor.

Good C++ programmers know what I'm talking about and
I'm sure that they would be happy to answer
any specific questions that you might have about
when and how to use the C++ exception handling mechanism.

Jul 22 '05 #14
E. Robert Tisdale wrote:
Gianni Mariani wrote:
What you wrote is ambiguous.
Are the points you wrote above recommendations or attempt at ESP?
There are a things you said there that *throw* alarm bells.

I can't help you with the ringing in your ears.
You need to see your doctor.

Good C++ programmers know what I'm talking about and
I'm sure that they would be happy to answer
any specific questions that you might have about
when and how to use the C++ exception handling mechanism.


I think I stated my question clearly - you posed your position
ambigously - are your points reccomendations or are they an attempt to
charaterize what the previous poster was thinking. You can answer the
question by either stating your position in the first person or you can
state them as positive or negative attribues to good programming.

I'm not sure, but the tone I read from your response is one of
superiority and condescension which should be kind of an embarasment for
you since you clearly assumed a position which is probably is likely to
alienate 50% of "Good C++" progammers. Asserting you are a good
programmer does not prove the case.

C++ exceptions are still one of the areas where there is lack of clear
concensus on the appropriate use. While I agree that the feauture is
useful, I think they lead to far more issues than they solve, and some
of the reasons you have stated in your earlier post.

Forgive me, but I don't know that you're as good as you assert(you are)
and so I am just not too sure you know which side of the points you >>
raise you fall on. catch( the drift ) ?

<below the belt> ... did you write exceptions for the Spirit rover ?
</below the belt> :=)

Jul 22 '05 #15
Gianni Mariani wrote:
I find that (lazy) programmers rely on exception handlers above them
in the stack frame to perform unknown magic.


Jul 22 '05 #16
E. Robert Tisdale wrote:
Gianni Mariani wrote:
> I find that (lazy) programmers rely on exception handlers above them
> > in the stack frame to perform unknown magic.


I'm still working on my mind and tarrot reading. I'll get back to you
when I know what you're talking about.

BTW - I'd look at the exception handlers on that Spirit rover, you've
got an unhandled exception ...

Jul 22 '05 #17
Gianni Mariani wrote:
E. Robert Tisdale wrote:
Gianni Mariani wrote:
> I find that (lazy) programmers rely on exception handlers above
> them
> > in the stack frame to perform unknown magic.


I'm still working on my mind and tarrot reading. I'll get back to you
when I know what you're talking about.


It probably _does_ take a rocket scientist to understand what he's
talking about. :-)

Jul 22 '05 #18
lilburne wrote:


Jorge Rivera wrote:
lilburne wrote:

After that everything else failing is a bug/algorithm failure, and
outside the scope of legitimate handling by exceptions.
What is an error? Other than user input problems, hardware failure, etc
I wouldn't accept that there are any errors that aren't bugs.
That's your definition of an error, and I guess I have the freedom of
designing my classes to define error as something different, right?

In your example how do *you* know that failure 'if(ret == -1)' wasn't what
I was coding for? By throwing an exception *you* have dictated that *my*
code
does its processing inside a catch block, which just seems plain odd.

But that's exactly what I want. I do not allow you to continue without
checking for the error. You CAN NOT ignore it, even if it causes you
the paing of processing the error in a catch block, it is better (and
ths is, of course, just my perspective and programming approach) than
just allowing you to ignore the return code.

Therefore, my design forces you to use my code in a way I feel confident
in saying that you can rely on.
Additionally even if I write *my* code such that your code never throws an
exception *you* still force me to pay the overhead of stack unwinding.


Well, I guess you would just hate my libraries, which is of course,
perfectly reasonable.

Thanks for the comments though, I will keep all that in mind for future
designs,

Jorge L.
Jul 22 '05 #19
Jorge Rivera wrote:
lilburne wrote:

In your example how do *you* know that failure 'if(ret == -1)' wasn't
what
I was coding for? By throwing an exception *you* have dictated that
*my* code
does its processing inside a catch block, which just seems plain odd.


But that's exactly what I want. I do not allow you to continue without
checking for the error. You CAN NOT ignore it, even if it causes you
the paing of processing the error in a catch block, it is better (and
ths is, of course, just my perspective and programming approach) than
just allowing you to ignore the return code.

Therefore, my design forces you to use my code in a way I feel confident
in saying that you can rely on.


Well I still don't know what you mean by an error, but you
could probably achieve the same by assertions. That way you
force me to fix my code in debug, and I don't pay for the
checks in release.
Additionally even if I write *my* code such that your code never
throws an
exception *you* still force me to pay the overhead of stack unwinding.


Well, I guess you would just hate my libraries, which is of course,
perfectly reasonable.


You'd probably hate mine too. Minimal runtime checking but
heavily laced with assertions. Violate a precondition and in
a debug run - kerboom.
Jul 22 '05 #20

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

Similar topics

11
2888
by: adi | last post by:
Dear all, This is more like a theoretical or conceptual question: which is better, using exception or return code for a .NET component? I had created a COM object (using VB6), which uses return code (not generating error/exception) so it is more compatible with other programming language.
7
6007
by: Noor | last post by:
please tell the technique of centralize exception handling without try catch blocks in c#.
3
2752
by: Master of C++ | last post by:
Hi, I am an absolute newbie to Exception Handling, and I am trying to retrofit exception handling to a LOT of C++ code that I've written earlier. I am just looking for a bare-bones, low-tech exception handling mechanism which will allow me to pass character information about an error and its location from lower-level classes. Can you please critique the following exception handling mechanism in terms of my requirements ?
2
2596
by: tom | last post by:
Hi, I am developing a WinForm application and I am looking for a guide on where to place Exception Handling. My application is designed into three tiers UI, Business Objects, and Data Access Layer. My questions is where should I put exception handling: 1) Should it be put in all significant methods in all layers? 2) Should I create an exception base class that will handle the errors and pass useful error messages to the user?
9
2538
by: C# Learner | last post by:
Some time ago, I remember reading a discussion about the strengths and weaknesses of exception handling. One of the weaknesses that was put forward was that exception handling is inefficient (in the way of CPU usage), compared to the "normal" practise returning values. How true is this? Will using using exception handling, in general, be much less efficient than returning values, or less efficient at all? Just curious...
44
4231
by: craig | last post by:
I am wondering if there are some best practices for determining a strategy for using try/catch blocks within an application. My current thoughts are: 1. The code the initiates any high-level user tasks should always be included in a try/catch block that actually handles any exceptions that occur (log the exception, display a message box, etc.). 2. Low-level operations that are used to carry out the high level tasks
4
5136
by: Ele | last post by:
When Exception handling disabled compiler still spits out "C++ exception handler used." Why is that? Why does it ask for "Specify /EHsc"? Thanks! c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\xstring(1453) : warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc
41
3081
by: Zytan | last post by:
Ok something simple like int.Parse(string) can throw these exceptions: ArgumentNullException, FormatException, OverflowException I don't want my program to just crash on an exception, so I must handle all of them. I don't care about which one happened, except to write out exception.Message to a log file. It seems verbose to write out three handlers that all do the same thing. So, I could just catch Exception. But, is that...
1
3110
by: George2 | last post by:
Hello everyone, Such code segment is used to check whether function call or exception- handling mechanism runs out of memory first (written by Bjarne), void perverted() { try{
0
9680
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9528
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10228
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10173
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10006
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9052
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5573
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2925
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.