2009-04-07 03:02:15 +00:00
|
|
|
//Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc.
|
2009-04-06 23:15:42 +00:00
|
|
|
|
|
|
|
//Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
|
|
|
|
#include <boost/config.hpp>
|
2020-12-22 17:26:53 -08:00
|
|
|
|
|
|
|
#if !defined( BOOST_NO_EXCEPTIONS )
|
|
|
|
# error This program requires exception handling disabled.
|
|
|
|
#endif
|
|
|
|
|
2009-04-06 23:15:42 +00:00
|
|
|
#include <boost/throw_exception.hpp>
|
|
|
|
#include <boost/exception/info.hpp>
|
|
|
|
#include <boost/exception/diagnostic_information.hpp>
|
2018-09-17 07:32:49 -04:00
|
|
|
#include <boost/core/lightweight_test.hpp>
|
2010-07-03 21:24:26 +00:00
|
|
|
#include <stdlib.h>
|
2009-04-06 23:15:42 +00:00
|
|
|
|
2009-12-04 01:29:22 +00:00
|
|
|
struct
|
|
|
|
my_exception:
|
|
|
|
boost::exception,
|
|
|
|
std::exception
|
|
|
|
{
|
|
|
|
char const *
|
2019-01-28 09:48:53 +02:00
|
|
|
what() const BOOST_NOEXCEPT_OR_NOTHROW
|
2009-12-04 01:29:22 +00:00
|
|
|
{
|
|
|
|
return "my_exception";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2009-04-06 23:15:42 +00:00
|
|
|
typedef boost::error_info<struct my_tag,int> my_int;
|
|
|
|
|
|
|
|
bool called=false;
|
|
|
|
|
|
|
|
namespace
|
|
|
|
boost
|
|
|
|
{
|
|
|
|
void
|
|
|
|
throw_exception( std::exception const & x )
|
|
|
|
{
|
|
|
|
called=true;
|
|
|
|
std::string s=boost::diagnostic_information(x);
|
|
|
|
std::cout << s;
|
|
|
|
#ifndef BOOST_NO_RTTI
|
|
|
|
BOOST_TEST(s.find("my_tag")!=std::string::npos);
|
|
|
|
#endif
|
2018-09-17 07:32:49 -04:00
|
|
|
exit(boost::report_errors());
|
2009-04-06 23:15:42 +00:00
|
|
|
}
|
2019-12-21 19:14:44 -08:00
|
|
|
void
|
|
|
|
throw_exception(std::exception const & x, boost::source_location const &)
|
|
|
|
{
|
|
|
|
throw_exception(x);
|
|
|
|
}
|
2009-04-06 23:15:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main()
|
|
|
|
{
|
|
|
|
BOOST_THROW_EXCEPTION( my_exception() << my_int(42) );
|
|
|
|
BOOST_TEST(called);
|
|
|
|
return boost::report_errors();
|
|
|
|
}
|