Kristofer Skaug
Re: Exceptions vs Error codes

Re: Exceptions vs Error codes

In article <3b7f9bd0$1_1@dnews>
	"Kristofer Skaug" <✉> wrote:

> "Barry Kelly" <✉> wrote in message
> news:✉
> >
> > I'm afraid I'm the reverse; exceptions *force* you to consider the
> > possibility of errors.
> so, isn't that pretty dictatorial?

"OK, in our next framework, we don't really care about errors. If you
want to know if you're headed for la-la land, you're going to have to
ask. We'll happily let you drive off a cliff with all you're customer's
data rather than let you know that something's awry."

> > Error codes are optional; an awful lot of code
> > can be written without regard for the error codes returned, and thus
> > will continue on blithely unaware of error conditions, mucking up
> state,
> > causing instability that isn't detected possibly for days, leading to
> > lots of $$$ loss.
> But errors are relative - one program's error can be another program's
> "don't care" (with respect to a generic library service). For example,
> say you call WinAPI functions to read out version info from a set of DLL
> files. If you are merely preparing information for you About box you may
> decide to ignore errors and simply print "Not found" for missing version
> info resources. In a configuration management program this is however
> critical and you may want to raise hell about it.
> I'd hate for those functions to *always* slap me with an exception for it
> though. A low-key error code is fine.

So wrap it in a little try..except that adds an appropriate error
message to the about box. I'd consider that much neater than losing the
richness of the error information and just blankly printing "Not found".

> It all depends on specification.
> So, depending on how you *intend* your code to work, but also depending
> on third party libraries, you may have to do a hell of a lot of exception
> quenching in the low level interfaces.
> If you basically consider that *every* function call in principle can
> fail, and treat the return codes with appropriate respect, you are no
> less safe than with exceptions. I don't need exceptions to remind me that
> code can fail.

You might not.

However, it appears you do simply by the very fact that you notice them.
-- Barry
--   If you're not part of the solution, you're part of the precipitate. Team JEDI: NNQ - Quoting Style in Newsgroup Postings
FYI: Phrase searches are enclosed in either single or double quotes
Originally created by
Tamarack Associates
Sun, 03 Mar 2024 22:07:10 UTC
Copyright © 2009-2024
HREF Tools Corp.