Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Visual Studio 2013 show unhandled exception message?

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?

like image 283
Anna Avatar asked Dec 17 '14 20:12

Anna


1 Answers

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.

like image 115
Roman L Avatar answered Oct 08 '22 18:10

Roman L