Re: How to get crash dump when a unhandled CException is thrown by a
MFC app
On Jan 6, 2:45 am, Joseph M. Newcomer <newco...@flounder.com> wrote:
I can only answer part of your question.
In VS, there is a way to turn on handling exceptions which intercepts the=
m at the point
where they occur; to enable this, go to Debug >Exceptions.
You might want to consider putting in some exception handlers of your own=
.. I'd looking at
Doug Harrison's article on exceptions at
http://members.cox.net/doug_web/eh.htm
Ultimately, when using exceptions, I found that the only good way to defe=
nd is to have
LOTS of try/catch blocks scattered widely. One system I worked in too =
a year of doing
this before I got every situation covered (and remember: if you write a t=
ry, you HAVE to
have a recovery strategy for the catch, or you haven't solved the problem=
.. That's what
takes the time. In many cases, you have to clean up with something lik=
e
catch(CException * e)
{
...do local cleanup...
throw;
}
No, good code should not have __any__ of these. Local cleanup in C++
is best handled through judicious application of RAII and it's more
powerful cousin, scope guard. ( I don't know why I started pressing
for scope guard here these days ;-) ).
(BTW, what you wrote there is the equivalent of a "finally" in...
ahem... lesser languages. C++ really has no need for finally.)
Application of RAII and scope guard also invalidates the notion that
good code needs lots of try/catch blocks. It doesn't, because most of
the time it will only do local cleanup and not re-throw a different
exception type (but if that's seen as needed, then try/catch it is).
Goran.