Re: How to catch an exception?
"Anders Eriksson" <anders@ostling.com> wrote in message
news:Onbz%23E6cHHA.3648@TK2MSFTNGP05.phx.gbl
"Igor Tandetnik" <itandetnik@mvps.org> wrote in message
news:O0B7mv5cHHA.4684@TK2MSFTNGP06.phx.gbl...
MFC exceptions are thrown by pointer. Make it
try {...}
catch (COleException* ex) {
ex->ReportError();
ex->Delete();
}
Somehow I have read something and drawn the conclusion that I should
us catch(CException &e)
That's indeed what you should do for sane exception systems (better
still, catch by reference to const). But MFC exceptions are not quite
sane: for certain technical and historical reasons, they are allocated
on the heap and thrown by pointer. Don't design your own exceptions this
way, realize that it's an unfortunate quirk of MFC.
--
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