"David Wilkinson" wrote:
I am writing MFC application, which version of exception
handle is better?
TRY/CATCH with MFC exceptions classes (or derived from
CException).
Are you saying you cannot (or should not) catch
CException* with try/catch? Surely you can, no?
Of course you can. Also, MS itself encourages to use C++
try/catch instead of MFC TRY/CATCH. However, the problem is
that you cannot stick with C++ handling and forget about
MFC's one. It always leaks, like in CFile usage, as Ulrich
pointed already. There are other places where MFC throws its
exceptions. Then in all these places you need to remember
that MFC exceptions are different (require deleting) from
the others. After while your code becomes inconsistent and
it's even worse than sticking with one of the handling
methods. So, I find it easier to stick with MFC exceptions
while making my own exceptions uniform with MFC's ones (by
deriving them from CExceptions or others). Then I don't need
to remember anything and can write same exception handling
code everywhere.