Um... it should be pretty obvious. You won't accidentally catch (swallow,
surpress) fatal errors.
Um...if the exception is fatal to the system you cannot swallow it;
otherwise it wouldn't be fatal. And
it should be pretty obvious for other exceptions, ones that are not fatal to
the system, what one application considers fatal might be non-fatal to
another.
No, it is because those discussions usually wander into a statements of
religious belief, not engineering, and from there into immature name
calling. It should be possible to discuss issues in a neutral manner.
The inherent problem is that the FCL's exception hierarchy is screwed up
(Jeffrey Richter wrote about it back in '02).
Got a link? I've read just about everything he has written, and I do not
know which article you are referring to. I recall one complaint he had about
a misleading exception when invoking a method via reflection, and it turns
out he was wrong.
I'm not muddying the
discussion, I'm referring to a *simple* system that has worked astonglishly
well for quite a few people.
Simply asserting that a system works well does not prove it. Some systems
work well for small systems but do not scale at all to large systems, nor do
they necessarily evolve well.
There are many limitations in the exception handling implementation in the
current version of .net; attempting to distinguish between a fatal system
error versus all others is one that is way down the list of items of
importance.
see below. Basically, if your application can run (i.e. the runtime is not
comprised) then it is recoverable.
Then we need new exception types. You cannot simply change the semantics of
an exception like that unless your code is meant *not* to be backward
compatible.
You are conflating many separate issues; adding new exception types does not
solve the problem. Modifying the exception hierarchy will not solve the
problem either. If it is a fatal system error then you are so hosed there is
little the application can do - the runtime usually crashes shortly
thereafter. There would be no value would in adding a few new exception
types.
For all other exceptions, if the integrity of the system has not been
comprised then by definition the exception is not fatal. It may be that the
application may be corrupted, but that would be the fault of the
application, not the system, and one that I would consider to be a bug in
the application.
If you are concerned that an exception has corrupted the application, which
is certainly a valid concern, then there should be a means of detecting that
condition, reporting it, and acting on it. This is entirely application
specific. However, this is not a condition that the runtime will have
knowledge of.
Maybe disguising is better a term than "masking", but the problem is that
even if you advise calling code to check inner exceptions explicitly, a
potentially fatal exception remains hidden initially. In my experience,
inner exceptions are rarely checked (just logged), but YMMV.
Actually, I never advise that the inner exception should be checked - I
advise against it. However, it is possible to clone the exception type, wrap
the original and throw a new one of the same type. This allows the code to
add context information without changing the technical reason for the
exception. One can also rethrow the original exception, which is similar to
not catching it at all, but this also does not provide a means of adding
context information.
Everything that makes the run-time bail out is fatal by default. That's the
"Error" category. These are the ones I'd like to see out of the mainstream
exception hierarchy.
If the runtime bails out you are done anyway - it typically will not let you
do anything of importance, and it may not even allow the catch handler to
run. I see little value in adding more exceptions that explicitly mean that
the runtime is corrupted.
But there is the danger of delaying a severe problem to a later point in
time that makes an application failure much more unpleasant than an
immediate termination.
The runtime usually halts immediately so nothing will propagate to a later
time because there is no later time. Even if it did, if the runtime's
integrity has been compromised I would not want it to run anyway - it may do
more damage then not running will do. I would rather the runtime terminate
immediately then run the risk of corrupting additional data.
It all depends on the test's implementation. You assume mocking. That's only
good for the facade's public API testing.
That is one type of unit test, but not the only one - you can unit test any
method, not just public APIs. A unit test tests a code unit, not the the
external code that it uses.
Sorry, but what notion of unit testing is that? Most code can't do anything
useful without calling into third party code.
Again, that is a system test, not a unit test. At some level you may assume
that some libraries (e.g. BCL) are constant and are part of the unit, but I
certainly would not make that assumption with a 3rd party library,
especially one that may generate side-effects.
See above. Inner exceptions are well disguised, and you require the caller
to check explicity.
Not at all - you misinterpreted what I wrote.
Cheers,