I am trying to write some general exception-handling logic for my C++ code, so that for *any* exception I log a stack trace to a file, and backup some data before the app crashes.
I am using an access violation as a test case, as in the following code:
First, I had to set the /EHa flag in Visual Studio to enable this exception to get caught at all. But now it is getting caught at the 'catch (...)' where I seemingly have no information about the exception.Code:try{ *((char*) 0) = 1; } catch (exception &e) { recorderror(e); } catch (...) { logerror("exception caught"); }
Inside the 'catch (...)', how can I determine what type of exception was caught and how can I generate the stack trace? I did some searching around and can't seem to find a solution.
I found a way to get the stack trace at the point inside the catch, but that doesn't help because this is code that is going to enclose my entire program. I need the stack trace from the point of the original exception.
Thanks!



LinkBack URL
About LinkBacks



