Re: unexpected exception handler
"George" <George@discussions.microsoft.com> wrote in message
news:0226EB22-2ECE-4FA2-A915-7FD93942EB05@microsoft.com
Do you think from technical point of view, it is possible to list all
the exceptions?
Yes and no. Generic library functions (like STL algorithms) can't really
do that, but they should a) carefully document exceptions they may
produce on their own, and under what conditions, and b) propagate
unchanged any exceptions that emanate from user-provided callbacks
(predicates, comparators, copy constructors, assignment operators and
the like). This allows the calling code to reliably know what exceptions
a library function may throw in the caller's particular circumstances.
On the other hand, high-level business logic functions can document all
exceptions they may throw. Functions at a module's boundary, at least,
should do that. They form the API for the module, and error handling
strategy is part of the API and should be documented.
I am not sure whether there are any potential
exceptions at runtime which we do not know at development time.
You sound as if exceptions just happen unpredictably, like earthquakes
or tornadoes. Computers are deterministic state machines. Exceptions
don't occur at random, they are thrown by some piece of code in your
application. You are basically saying that you have no idea what your
code is doing. That's not a good way to develop software.
--
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