mirror of
https://github.com/boostorg/exception.git
synced 2025-07-29 12:07:20 +02:00
Added verbose parameter to boost::diagnostic_information.
[SVN r82179]
This commit is contained in:
@ -25,8 +25,7 @@ boost
|
||||
{
|
||||
public:
|
||||
|
||||
virtual std::string tag_typeid_name() const = 0;
|
||||
virtual std::string value_as_string() const = 0;
|
||||
virtual std::string name_value_string() const = 0;
|
||||
|
||||
protected:
|
||||
|
||||
@ -63,8 +62,7 @@ boost
|
||||
|
||||
private:
|
||||
|
||||
std::string tag_typeid_name() const;
|
||||
std::string value_as_string() const;
|
||||
std::string name_value_string() const;
|
||||
|
||||
value_type value_;
|
||||
};
|
||||
|
@ -467,7 +467,7 @@ boost
|
||||
|
||||
inline
|
||||
std::string
|
||||
diagnostic_information( exception_ptr const & p )
|
||||
diagnostic_information( exception_ptr const & p, bool verbose=true )
|
||||
{
|
||||
if( p )
|
||||
try
|
||||
@ -477,7 +477,7 @@ boost
|
||||
catch(
|
||||
... )
|
||||
{
|
||||
return current_exception_diagnostic_information();
|
||||
return current_exception_diagnostic_information(verbose);
|
||||
}
|
||||
return "<empty>";
|
||||
}
|
||||
|
@ -31,17 +31,17 @@ boost
|
||||
namespace
|
||||
exception_detail
|
||||
{
|
||||
std::string diagnostic_information_impl( boost::exception const *, std::exception const *, bool );
|
||||
std::string diagnostic_information_impl( boost::exception const *, std::exception const *, bool, bool );
|
||||
}
|
||||
|
||||
inline
|
||||
std::string
|
||||
current_exception_diagnostic_information()
|
||||
current_exception_diagnostic_information( bool verbose=true)
|
||||
{
|
||||
boost::exception const * be=current_exception_cast<boost::exception const>();
|
||||
std::exception const * se=current_exception_cast<std::exception const>();
|
||||
if( be || se )
|
||||
return exception_detail::diagnostic_information_impl(be,se,true);
|
||||
return exception_detail::diagnostic_information_impl(be,se,true,verbose);
|
||||
else
|
||||
return "No diagnostic information available.";
|
||||
}
|
||||
@ -107,7 +107,7 @@ boost
|
||||
|
||||
inline
|
||||
std::string
|
||||
diagnostic_information_impl( boost::exception const * be, std::exception const * se, bool with_what )
|
||||
diagnostic_information_impl( boost::exception const * be, std::exception const * se, bool with_what, bool verbose )
|
||||
{
|
||||
if( !be && !se )
|
||||
return "Unknown exception.";
|
||||
@ -125,7 +125,7 @@ boost
|
||||
return wh;
|
||||
}
|
||||
std::ostringstream tmp;
|
||||
if( be )
|
||||
if( be && verbose )
|
||||
{
|
||||
char const * const * f=get_error_info<throw_file>(*be);
|
||||
int const * l=get_error_info<throw_line>(*be);
|
||||
@ -149,36 +149,37 @@ boost
|
||||
}
|
||||
}
|
||||
#ifndef BOOST_NO_RTTI
|
||||
tmp << std::string("Dynamic exception type: ") <<
|
||||
units::detail::demangle((be?(BOOST_EXCEPTION_DYNAMIC_TYPEID(*be)):(BOOST_EXCEPTION_DYNAMIC_TYPEID(*se))).type_->name()) << '\n';
|
||||
if ( verbose )
|
||||
tmp << std::string("Dynamic exception type: ") <<
|
||||
units::detail::demangle((be?(BOOST_EXCEPTION_DYNAMIC_TYPEID(*be)):(BOOST_EXCEPTION_DYNAMIC_TYPEID(*se))).type_->name()) << '\n';
|
||||
#endif
|
||||
if( with_what && se )
|
||||
if( with_what && se && verbose )
|
||||
tmp << "std::exception::what: " << wh << '\n';
|
||||
if( be )
|
||||
if( char const * s=exception_detail::get_diagnostic_information(*be,tmp.str().c_str()) )
|
||||
if( *s )
|
||||
return s;
|
||||
return std::string(s);
|
||||
return tmp.str();
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
std::string
|
||||
diagnostic_information( T const & e )
|
||||
diagnostic_information( T const & e, bool verbose=true )
|
||||
{
|
||||
return exception_detail::diagnostic_information_impl(exception_detail::get_boost_exception(&e),exception_detail::get_std_exception(&e),true);
|
||||
return exception_detail::diagnostic_information_impl(exception_detail::get_boost_exception(&e),exception_detail::get_std_exception(&e),true,verbose);
|
||||
}
|
||||
|
||||
inline
|
||||
char const *
|
||||
diagnostic_information_what( exception const & e ) throw()
|
||||
diagnostic_information_what( exception const & e, bool verbose=true ) throw()
|
||||
{
|
||||
char const * w=0;
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
#endif
|
||||
(void) exception_detail::diagnostic_information_impl(&e,0,false);
|
||||
(void) exception_detail::diagnostic_information_impl(&e,0,false,verbose);
|
||||
if( char const * di=exception_detail::get_diagnostic_information(e,0) )
|
||||
return di;
|
||||
else
|
||||
|
@ -24,10 +24,18 @@ boost
|
||||
{
|
||||
template <class Tag,class T>
|
||||
inline
|
||||
typename enable_if<has_to_string<T>,std::string>::type
|
||||
std::string
|
||||
error_info_name( error_info<Tag,T> const & x )
|
||||
{
|
||||
return tag_type_name<Tag>();
|
||||
}
|
||||
|
||||
template <class Tag,class T>
|
||||
inline
|
||||
std::string
|
||||
to_string( error_info<Tag,T> const & x )
|
||||
{
|
||||
return to_string(x.value());
|
||||
return '[' + error_info_name(x) + "] = " + to_string_stub(x.value()) + '\n';
|
||||
}
|
||||
|
||||
template <class Tag,class T>
|
||||
@ -49,16 +57,7 @@ boost
|
||||
inline
|
||||
std::string
|
||||
error_info<Tag,T>::
|
||||
tag_typeid_name() const
|
||||
{
|
||||
return tag_type_name<Tag>();
|
||||
}
|
||||
|
||||
template <class Tag,class T>
|
||||
inline
|
||||
std::string
|
||||
error_info<Tag,T>::
|
||||
value_as_string() const
|
||||
name_value_string() const
|
||||
{
|
||||
return to_string_stub(*this);
|
||||
}
|
||||
@ -114,7 +113,7 @@ boost
|
||||
for( error_info_map::const_iterator i=info_.begin(),end=info_.end(); i!=end; ++i )
|
||||
{
|
||||
error_info_base const & x = *i->second;
|
||||
tmp << '[' << x.tag_typeid_name() << "] = " << x.value_as_string() << '\n';
|
||||
tmp << x.name_value_string();
|
||||
}
|
||||
tmp.str().swap(diagnostic_info_str_);
|
||||
}
|
||||
|
Reference in New Issue
Block a user