Re: unexpected exception handler
- From: George <George@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 8 Jan 2008 19:35:01 -0800
Thanks Igor,
Do you think from technical point of view, it is possible to list all the
exceptions? I am not sure whether there are any potential exceptions at
runtime which we do not know at development time.
regards,
George
"Igor Tandetnik" wrote:
George <George@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:.
I hear some points to support exception specification is because,
only if developer could clearly list all the possible exceptions a
function may thrown, it is well designed function -- all exception
situations are thought.
List them in a comment next to the function declaration, or in the
documentation.
Realize that the compiler has to actually generate code to enforce
exception specification at runtime. If you know your function never
throws exceptions other than those on the list, by writing an exception
specification you force the compiler to generate dead code that you know
will never run. And if you know your function _will_ throw exceptions
outside the list, then what's the point of putting in an exception
specification that's essentially a lie?
If we do not have exception specification, and simply catch(...),
there may be some exceptions we (developer) never thought of in
design/implementation.
If there are exceptions you didn't think of, then you can't clearly list
all the possible exceptions a function may throw. By your own
definition, such a function is not well designed. So go back and design
it better.
I don't see how catch(...) is helpful. What are you going to do in such
a handler, other than perhaps some cleanup and then rethrow?
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
- Follow-Ups:
- Re: unexpected exception handler
- From: Tamas Demjen
- Re: unexpected exception handler
- From: Igor Tandetnik
- Re: unexpected exception handler
- References:
- Re: unexpected exception handler
- From: Igor Tandetnik
- Re: unexpected exception handler
- From: George
- Re: unexpected exception handler
- From: Igor Tandetnik
- Re: unexpected exception handler
- From: Igor Tandetnik
- Re: unexpected exception handler
- Prev by Date: Re: DLLs and Sharing Memory
- Next by Date: Re: Double-Checked Locking pattern issue
- Previous by thread: Re: unexpected exception handler
- Next by thread: Re: unexpected exception handler
- Index(es):
Relevant Pages
|