I’ve got a c++ app that wraps large parts of code in try blocks. When I catch exceptions I can return the user to a stable state, which is nice. But I’m not longer receiving crash dumps. I’d really like to figure out where in the code the exception is taking place, so I can log it and fix it.
Being able to get a dump without halting the application would be ideal, but I’m not sure that’s possible.
Is there some way I can figure out where the exception was thrown from within the catch block? If it’s useful, I’m using native msvc++ on windows xp and higher. My plan is to simply log the crashes to a file on the various users’ machines, and then upload the crashlogs once they get to a certain size.
This is possible with using SEH (structured exception handling). The point is that MSVC implements C++ exceptions via SEH. On the other hand the pure SEH is much more powerful and flexible.
That’s what you should do. Instead of using pure C++ try/catch blocks like this:
You should wrap the inner code block
DoSomethingwith the SEH block:That is, inside the C++ try/catch block we place another raw SEH block, which only dumps all the exceptions without catching them.
See here for an example of using MiniDumpWriteDump.