c++exceptiontry-catchextract-error-message

C++ retrieve exception information


I have a c++ dll which I need to debug. Due to the circumstances in which I am using the dll, I am unable to debug it via the calling application.

So, I created a try -catch, where the catch writes the exception to a file.

The line which needs to be debugged involves imported classes from a 3rd party dll, so I have no way of knowing what type of exception it is. When I tried catch(exception e), no message was written to the file. So I tried catch(...), which did trigger something:

using std::exception::what, the only thing that got written to the file was "1". using std::exception::exception, the file received the following code : "0579EF90".

Is there any way for me to retrieve meaningful info about the exception that was thrown?

TIA

CG


Solution

  • If you don't use catch(KnownExceptionType ex) and use your knwoledge about KnownExceptionType to extract info, no you can't.

    When you catch with catch(...) you are pretty much lost, you know that you handled an exception but there is no type information there, there is little you can do.

    You are in the worse case, an exception coming out from a library, you have no info on the exception, even if you had headers for the lib, that exception type doesn't need to be defined there.