Re: Tasty exceptions
- From: "Craig Stuntz [TeamB]" <craig_stuntz@xxxxxxxxxxxxx [a.k.a. acm.org]>
- Date: 30 Jun 2006 11:44:58 -0700
Michael C. wrote:
Generally, I can see 2 advantages to turning an exception into an
error code:
1) To suppress useless exceptions.
Sometimes all you want to know is if something succeeded or failed.
In this case, you could really care less what the exception was and
you still want your programs execution to proceed.
Allowing a program to proceed in an undefined state is hazardous to
software reliability. You can assert you don't care why something
failed, but if it failed because the stack was corrupt you're going to
care sooner or later. The question is what your app does before it
starts "caring."
2) Sometimes one can respond more efficiently to an error code using
a case or an if statement instead of using an exception handler.
That's putting the cart before the horse, IMHO. Optimize an error
handler? If this is causing an issue in your app then "efficiency" is
/not/ the problem.
An object can be in a defined state while dealing with all local
exceptions locally. That wouldn't be dangerous.
Precisely what is a "local" exception? Surely you don't think that an
exception raised by a piece of code of a well-defined scope must have
only "local" consequences, right? The only exceptions which are safe to
"handle" are those you expect, and they aren't the only ones trapped in
an empty exception handler. Handling expected exceptions is covered by
the first of the two correct responses I enumerated earlier (which come
from Meyer, not me, BTW).
--
Craig Stuntz [TeamB] · Vertex Systems Corp. · Columbus, OH
Delphi/InterBase Weblog : http://blogs.teamb.com/craigstuntz
Everything You Need to Know About InterBase Character Sets:
http://blogs.teamb.com/craigstuntz/articles/403.aspx
.
- References:
- Tasty exceptions
- From: Blackbird Crow Raven
- Re: Tasty exceptions
- From: Nick Hodges (Borland/DevCo)
- Re: Tasty exceptions
- From: Arthur Hoornweg
- Re: Tasty exceptions
- From: Jon Robertson
- Re: Tasty exceptions
- From: Craig Stuntz [TeamB]
- Re: Tasty exceptions
- From: Michael C.
- Re: Tasty exceptions
- From: Craig Stuntz [TeamB]
- Re: Tasty exceptions
- From: Michael C.
- Re: Tasty exceptions
- From: Craig Stuntz [TeamB]
- Re: Tasty exceptions
- From: Michael C.
- Tasty exceptions
- Prev by Date: Re: The Top Ten Niggling, Irritating, and Downright Bad IDE Bugs List
- Next by Date: Re: Tasty exceptions
- Previous by thread: Re: Tasty exceptions
- Next by thread: Re: Tasty exceptions
- Index(es):
Relevant Pages
|
|