Boost :: exception - how to print data?

I have this code in my program:

catch (boost::exception& ex) { // error handling } 

How to print the details? Error message, stacktrace etc.

+8
c ++ boost
source share
2 answers

For something in common, like boost::exception , I think you're looking for the boost::diagnostic_information function to get a nice string representation.

To get the stack for the exception, I would start by asking StackOverflow the trace stack of the C ++ screen stack for the exception .

+3
source share

You can use boost :: diagnost_information () to get the actual error messages and the origin of the exception. i.e.

 catch (const boost::exception& ex) { // error handling std::cerr << boost::diagnostic_information(ex); } 
+6
source share

All Articles