Jump to content
  • Advertisement
Sign in to follow this  

c++ exception handling in an MFC application

This topic is 4848 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!