
Hello I'm trying to nest exceptions using boost.Exception, but it seems like some information (in this case the message returned via what() ) is lost on the way. #include <iostream> #include <boost/exception.hpp> typedef boost::error_info<struct tag_nested_exception, boost::exception_ptr> nested_exception; struct file_open_error : public boost::exception, public std::exception {}; int open_file(const std::string& filename) { try { // ... throw std::runtime_error("Some internal error."); } catch(const std::exception& error) { throw file_open_error() << nested_exception(boost::copy_exception(error)); } } int main(int argc, char* argv[]) { try { int file = open_file("foo.txt"); file++; } catch(const boost::exception& error) { try { boost::rethrow_exception(*boost::get_error_info<nested_exception>(error)); } catch(const std::exception& nested) { std::cout << "the nested error is: " << nested.what() << std::endl; } } return 0; } I except the output to be "the nested error is: Some internal error." but it outputs "the nested error is: std::exception". What can I do to make it work? Greetings Pascal