Sign in to follow this  
kovacsp

c++ exception handling in an MFC application

Recommended Posts

kovacsp    306
Hi, my problem looks simple but I can't find a solution for days. I want to catch all unhandled c++ exceptions in my program, which is an MFC program (I cannot change this). I don't want to use the TRY, CATCH, etc macros, because they are ugly, and AFAIK microsoft told them to be obsolate. If I would use MFC exceptions (derived from CEXception), I could override ProcessWndProcException of my CWinApp, and catch all unhadled exceptions that are thrown from the message loop. This approach has another problem, it cannot catch exceptions before the message loop, that is, I cannot catch exceptions thrown in the initialization code (and that is huge here). I also have a crash handler, that catches fatal errors (null pointer dereference), but this is not what I want. The simplest thing to do was to write a try {} catch around the main() but since it's MFC, I don't have the main! All I want is method for catching simple, pure c++ exceptions that are not caught by anyone, and handle it as I want. (I have an exception class that creates a call stack when created but I cannot print it if I cannoit catch it, and the default handler will not do it for me.) Thanks for your help, Peter

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this