I throw this error in my C++ program and don't handle it:
throw std::runtime_error("X failed because " + my_string);
I compile and run it with Visual Studio 2013, and get the following error:
Unhandled exception at 0x7617C42D in bla.exe: Microsoft C++ exception: std::runtime_error at memory location 0x009FEA98.
How can I see the message "X failed because ..." without handling the error in the code?
If you are just trying to figure out which exception caused your program to terminate while debugging, you can simply Break then navigate the call stack to see where the exception is thrown.
If you are in the Debug mode, the top of the call stack will probably point at _CxxThrowException
. In that case, you could inspect its argument pExceptionObject
and even add something like ((std::exception*)pExceptionObject)->what()
to the watch list. However, this relies on a few assumptions that are not always valid.
It is really easier to add a catch (std::exception& e)
and inspect the error there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With