Newsgroups: comp.lang.c++.moderated
From: David Abrahams <d...@boost-consulting.com>
Date: 31 Aug 2005 17:05:05 -0400
Local: Wed, Aug 31 2005 5:05 pm
Subject: Re: Exceptions
"Nicola Musatti" <nicola.musa...@gmail.com> writes: Sure. If you want to throw an exception there, just document it and > Bob Bell wrote: >> Gerhard Menzl wrote: >> > Bob Bell wrote: >> > > I should be more specific. I interpret "the function cannot continue" >> > Not even log and assert? >> If I said "it's OK to log and assert", would that invalidate my point > Excuse me, but don't you risk assuming too much in the other direction? > double safeSqrt(double arg) { > Wouldn't it be a bit extreme to assume the world has ended just because don't call arg >= 0 a precondition. If you call it a precondition, invoking safeSqrt with a negative If it's a precondition, and you want to write code that tries to take > On the other hand I agree that if the world has actually ended, we That's not Bob's point at all. > wouldn't want to add damage to it. So what can we do about it? You are > probably right that exception handling is not to be trusted > and it seems to me that the least action you can take is to return a No. If you want your code to be robust, be clear about the difference > conventional value. > Should we reach the conclusion that returning error codes is better between preconditions and the conditions that generate error codes and exceptions. Some people like to avoid the word "error" in connection with the _Programmer errors_ lead to precondition failures which invoke _Exceptional conditions_, such as resource allocation failures Is that clearer? [ See http://www.gotw.ca/resources/clcm.htm for info about ] You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||