2008-08-28 23:49:55 +00:00
|
|
|
//Copyright (c) 2006-2008 Emil Dotchevski and Reverge Studios, Inc.
|
|
|
|
|
|
|
|
//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)
|
|
|
|
|
|
|
|
#ifndef UUID_1A590226753311DD9E4CCF6156D89593
|
|
|
|
#define UUID_1A590226753311DD9E4CCF6156D89593
|
|
|
|
|
2008-08-30 02:57:12 +00:00
|
|
|
#include <boost/exception/exception.hpp>
|
2008-08-28 23:49:55 +00:00
|
|
|
#include <boost/exception/detail/error_info_base.hpp>
|
2008-08-30 02:57:12 +00:00
|
|
|
#include <boost/exception/detail/type_info.hpp>
|
|
|
|
#include <boost/shared_ptr.hpp>
|
2008-08-28 23:49:55 +00:00
|
|
|
|
|
|
|
namespace
|
|
|
|
boost
|
|
|
|
{
|
|
|
|
namespace
|
|
|
|
exception_detail
|
|
|
|
{
|
|
|
|
template <class ErrorInfo>
|
|
|
|
inline
|
|
|
|
shared_ptr<typename ErrorInfo::value_type const>
|
2008-08-31 04:05:19 +00:00
|
|
|
get_info( exception const & x )
|
2008-08-28 23:49:55 +00:00
|
|
|
{
|
2008-08-31 01:39:00 +00:00
|
|
|
if( exception_detail::error_info_container * c=x.data_.get() )
|
|
|
|
if( shared_ptr<exception_detail::error_info_base const> eib = c->get(BOOST_EXCEPTION_STATIC_TYPEID(ErrorInfo)) )
|
2008-08-28 23:49:55 +00:00
|
|
|
{
|
|
|
|
#ifndef BOOST_NO_RTTI
|
|
|
|
BOOST_ASSERT( 0!=dynamic_cast<ErrorInfo const *>(eib.get()) );
|
|
|
|
#endif
|
|
|
|
ErrorInfo const * w = static_cast<ErrorInfo const *>(eib.get());
|
|
|
|
return shared_ptr<typename ErrorInfo::value_type const>(eib,&w->value());
|
|
|
|
}
|
|
|
|
return shared_ptr<typename ErrorInfo::value_type const>();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-30 02:57:12 +00:00
|
|
|
#ifdef BOOST_NO_RTTI
|
|
|
|
template <class ErrorInfo>
|
|
|
|
inline
|
|
|
|
shared_ptr<typename ErrorInfo::value_type const>
|
|
|
|
get_error_info( boost::exception const & x )
|
|
|
|
{
|
2008-08-31 04:05:19 +00:00
|
|
|
return exception_detail::get_info<ErrorInfo>(x);
|
2008-08-30 02:57:12 +00:00
|
|
|
}
|
|
|
|
#else
|
2008-08-28 23:49:55 +00:00
|
|
|
template <class ErrorInfo,class E>
|
|
|
|
inline
|
|
|
|
shared_ptr<typename ErrorInfo::value_type const>
|
|
|
|
get_error_info( E const & some_exception )
|
|
|
|
{
|
2008-08-30 02:57:12 +00:00
|
|
|
if( exception const * x = dynamic_cast<exception const *>(&some_exception) )
|
2008-08-31 04:05:19 +00:00
|
|
|
return exception_detail::get_info<ErrorInfo>(*x);
|
2008-08-28 23:49:55 +00:00
|
|
|
else
|
|
|
|
return shared_ptr<typename ErrorInfo::value_type const>();
|
|
|
|
}
|
2008-08-30 02:57:12 +00:00
|
|
|
#endif
|
2008-08-28 23:49:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|