1 //Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc. 2 3 //Distributed under the Boost Software License, Version 1.0. (See accompanying 4 //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 6 #include <boost/exception/error_info.hpp> 7 #include <boost/exception/exception.hpp> 8 #include <boost/exception/info.hpp> 9 #include <boost/exception/get_error_info.hpp> 10 #include <boost/core/lightweight_test.hpp> 11 #include <string> 12 #include <string.h> 13 14 struct my_exception: virtual boost::exception {}; 15 typedef boost::error_info<struct error_info_string_, std::string> error_info_string; 16 17 int main()18main() 19 { 20 try 21 { 22 throw my_exception() << error_info_string("doh"); 23 } 24 catch( my_exception & e ) 25 { 26 BOOST_TEST(boost::get_error_info<error_info_string>(e) && !strcmp(boost::get_error_info<error_info_string>(e)->c_str(),"doh")); 27 } 28 return boost::report_errors(); 29 } 30