mirror of
https://github.com/boostorg/exception.git
synced 2025-07-26 02:27:15 +02:00
minor diagnostic_information maintenance, updated documentation
[SVN r58131]
This commit is contained in:
@ -47,7 +47,7 @@ boost
|
|||||||
<span class="RenoIncludeSPAN">void <span class="RenoLink"><a href="rethrow_exception.html">rethrow_exception</a></span>( <span class="RenoLink"><a href="exception_ptr.html">exception_ptr</a></span> const & ep );</span></span>
|
<span class="RenoIncludeSPAN">void <span class="RenoLink"><a href="rethrow_exception.html">rethrow_exception</a></span>( <span class="RenoLink"><a href="exception_ptr.html">exception_ptr</a></span> const & ep );</span></span>
|
||||||
}</pre>
|
}</pre>
|
||||||
</div></div><div class="RenoAutoDIV"><div class="RenoHR"><hr/></div>
|
</div></div><div class="RenoAutoDIV"><div class="RenoHR"><hr/></div>
|
||||||
See also: <span class="RenoPageList"><a href="boost_exception_all_hpp.html">boost/exception/all.hpp</a> | <a href="copy_exception.html">copy_exception</a> | <a href="current_exception.html">current_exception</a> | <a href="exception_ptr.html">exception_ptr</a> | <a href="original_exception_type.html">original_exception_type</a> | <a href="rethrow_exception.html">rethrow_exception</a> | <a href="synopsis.html">Synopsis</a> | <a href="unknown_exception.html">unknown_exception</a></span>
|
See also: <span class="RenoPageList"><a href="boost_exception_all_hpp.html">boost/exception/all.hpp</a> | <a href="copy_exception.html">copy_exception</a> | <a href="current_exception.html">current_exception</a> | <a href="diagnostic_information.html">diagnostic_information</a> | <a href="exception_ptr.html">exception_ptr</a> | <a href="original_exception_type.html">original_exception_type</a> | <a href="rethrow_exception.html">rethrow_exception</a> | <a href="synopsis.html">Synopsis</a> | <a href="unknown_exception.html">unknown_exception</a></span>
|
||||||
</div>
|
</div>
|
||||||
<!-- Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc. -->
|
<!-- Copyright (c) 2006-2009 Emil Dotchevski and Reverge Studios, Inc. -->
|
||||||
<!-- Distributed under the Boost Software License, Version 1.0. (See accompanying -->
|
<!-- Distributed under the Boost Software License, Version 1.0. (See accompanying -->
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
<!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
|
<!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
|
||||||
<div class="RenoIncludeDIV"><div class="RenoAutoDIV"><h3>diagnostic_information</h3>
|
<div class="RenoIncludeDIV"><div class="RenoAutoDIV"><h3>diagnostic_information</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="RenoIncludeDIV"><p><span class="RenoEscape">#<!--<wiki>`#</wiki>--></span>include <<span class="RenoLink"><a href="boost_exception_diagnostic_information_hpp.html">boost/exception/diagnostic_information.hpp</a></span>><span class="RenoBR"> </span><br/></p>
|
<div class="RenoIncludeDIV"><p><span class="RenoEscape">#<!--<wiki>`#</wiki>--></span>include <<span class="RenoLink"><a href="boost_exception_diagnostic_information_hpp.html">boost/exception/diagnostic_information.hpp</a></span>><span class="RenoBR"> </span><br/><span class="RenoEscape">#<!--<wiki>`#</wiki>--></span>include <<span class="RenoLink"><a href="boost_exception_ptr_hpp.html">boost/exception_ptr.hpp</a></span>><span class="RenoBR"> </span><br/></p>
|
||||||
<pre>namespace
|
<pre>namespace
|
||||||
boost
|
boost
|
||||||
{
|
{
|
||||||
@ -33,7 +33,7 @@ boost
|
|||||||
</div><h4>Returns:</h4>
|
</div><h4>Returns:</h4>
|
||||||
<p>A string value that contains varying amount of implementation-specific diagnostic information about the passed object:</p>
|
<p>A string value that contains varying amount of implementation-specific diagnostic information about the passed object:</p>
|
||||||
<div><ul><li>If E can be statically converted to boost::<span class="RenoLink"><a href="exception.html">exception</a></span>, the returned value contains the string representations of all <span class="RenoLink"><a href="error_info.html">error_info</a></span> objects stored in the boost::<span class="RenoLink"><a href="exception.html">exception</a></span> through <span class="RenoLink"><a href="exception_operator_shl.html">operator<<</a></span>, along with other diagnostic information relevant to the exception. If e can be dynamically converted to std::exception, the returned value also contains the what() string.</li>
|
<div><ul><li>If E can be statically converted to boost::<span class="RenoLink"><a href="exception.html">exception</a></span>, the returned value contains the string representations of all <span class="RenoLink"><a href="error_info.html">error_info</a></span> objects stored in the boost::<span class="RenoLink"><a href="exception.html">exception</a></span> through <span class="RenoLink"><a href="exception_operator_shl.html">operator<<</a></span>, along with other diagnostic information relevant to the exception. If e can be dynamically converted to std::exception, the returned value also contains the what() string.</li>
|
||||||
<li>Otherwise, if E can be statically converted std::exception:<div><ul><li>if e can be dynamically converted to boost::exception, the returned value is the same as if E could be statically converted to boost::<span class="RenoLink"><a href="exception.html">exception</a></span>;</li>
|
<li>Otherwise, if E can be statically converted to std::exception:<div><ul><li>if e can be dynamically converted to boost::exception, the returned value is the same as if E could be statically converted to boost::<span class="RenoLink"><a href="exception.html">exception</a></span>;</li>
|
||||||
<li>otherwise the returned value contains the what() string.</li>
|
<li>otherwise the returned value contains the what() string.</li>
|
||||||
</ul></div>
|
</ul></div>
|
||||||
</li>
|
</li>
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -42,8 +42,7 @@ boost
|
|||||||
void rethrow_exception( exception_ptr const & );
|
void rethrow_exception( exception_ptr const & );
|
||||||
|
|
||||||
class
|
class
|
||||||
exception_ptr:
|
exception_ptr
|
||||||
public exception_detail::exception_ptr_base
|
|
||||||
{
|
{
|
||||||
typedef bool exception_ptr::*unspecified_bool_type;
|
typedef bool exception_ptr::*unspecified_bool_type;
|
||||||
friend exception_ptr current_exception();
|
friend exception_ptr current_exception();
|
||||||
@ -72,7 +71,7 @@ boost
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_rethrow() const
|
rethrow() const
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(*this);
|
BOOST_ASSERT(*this);
|
||||||
if( bad_alloc_ )
|
if( bad_alloc_ )
|
||||||
@ -82,7 +81,7 @@ boost
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
_empty() const
|
empty() const
|
||||||
{
|
{
|
||||||
return !bad_alloc_ && !c_;
|
return !bad_alloc_ && !c_;
|
||||||
}
|
}
|
||||||
@ -100,7 +99,7 @@ boost
|
|||||||
|
|
||||||
operator unspecified_bool_type() const
|
operator unspecified_bool_type() const
|
||||||
{
|
{
|
||||||
return _empty() ? 0 : &exception_ptr::bad_alloc_;
|
return empty() ? 0 : &exception_ptr::bad_alloc_;
|
||||||
}
|
}
|
||||||
|
|
||||||
friend
|
friend
|
||||||
@ -443,7 +442,24 @@ boost
|
|||||||
void
|
void
|
||||||
rethrow_exception( exception_ptr const & p )
|
rethrow_exception( exception_ptr const & p )
|
||||||
{
|
{
|
||||||
p._rethrow();
|
p.rethrow();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
std::string
|
||||||
|
diagnostic_information( exception_ptr const & p )
|
||||||
|
{
|
||||||
|
if( p )
|
||||||
|
try
|
||||||
|
{
|
||||||
|
rethrow_exception(p);
|
||||||
|
}
|
||||||
|
catch(
|
||||||
|
... )
|
||||||
|
{
|
||||||
|
return current_exception_diagnostic_information();
|
||||||
|
}
|
||||||
|
return "<empty>";
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
//Copyright (c) 2006-2009 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_DC4208C6417811DEBF11E1EC55D89593
|
|
||||||
#define UUID_DC4208C6417811DEBF11E1EC55D89593
|
|
||||||
|
|
||||||
#if defined(__GNUC__) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS)
|
|
||||||
#pragma GCC system_header
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace
|
|
||||||
boost
|
|
||||||
{
|
|
||||||
namespace
|
|
||||||
exception_detail
|
|
||||||
{
|
|
||||||
class
|
|
||||||
exception_ptr_base
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
virtual void _rethrow() const=0;
|
|
||||||
virtual bool _empty() const=0;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
~exception_ptr_base() throw()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -12,13 +12,37 @@
|
|||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#include <boost/exception/get_error_info.hpp>
|
#include <boost/exception/get_error_info.hpp>
|
||||||
#include <boost/exception/detail/exception_ptr_base.hpp>
|
|
||||||
#include <boost/utility/enable_if.hpp>
|
#include <boost/utility/enable_if.hpp>
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#ifndef BOOST_NO_EXCEPTIONS
|
||||||
|
#include <boost/exception/current_exception_cast.hpp>
|
||||||
|
namespace
|
||||||
|
boost
|
||||||
|
{
|
||||||
|
namespace
|
||||||
|
exception_detail
|
||||||
|
{
|
||||||
|
std::string diagnostic_information_impl( boost::exception const *, std::exception const *, bool );
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
std::string
|
||||||
|
current_exception_diagnostic_information()
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
else
|
||||||
|
return "No diagnostic information available.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
boost
|
boost
|
||||||
{
|
{
|
||||||
@ -27,7 +51,7 @@ boost
|
|||||||
{
|
{
|
||||||
template <class T>
|
template <class T>
|
||||||
struct
|
struct
|
||||||
enable_boost_exception_overload
|
is_convertible_to_boost_exception
|
||||||
{
|
{
|
||||||
struct yes { char q[100]; };
|
struct yes { char q[100]; };
|
||||||
typedef char no;
|
typedef char no;
|
||||||
@ -38,13 +62,13 @@ boost
|
|||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
struct
|
struct
|
||||||
enable_std_exception_overload
|
is_convertible_to_std_exception
|
||||||
{
|
{
|
||||||
struct yes { char q[100]; };
|
struct yes { char q[100]; };
|
||||||
typedef char no;
|
typedef char no;
|
||||||
static yes check(std::exception const *);
|
static yes check(std::exception const *);
|
||||||
static no check(...);
|
static no check(...);
|
||||||
enum e { value = !enable_boost_exception_overload<T>::value && sizeof(check((T*)0))==sizeof(yes) };
|
enum e { value = sizeof(check((T*)0))==sizeof(yes) };
|
||||||
};
|
};
|
||||||
|
|
||||||
inline
|
inline
|
||||||
@ -70,12 +94,13 @@ boost
|
|||||||
std::string
|
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 )
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(be||se);
|
if( !be && !se )
|
||||||
|
return "Unknown exception.";
|
||||||
#ifndef BOOST_NO_RTTI
|
#ifndef BOOST_NO_RTTI
|
||||||
if( !se )
|
|
||||||
se = dynamic_cast<std::exception const *>(be);
|
|
||||||
if( !be )
|
if( !be )
|
||||||
be = dynamic_cast<boost::exception const *>(se);
|
be=dynamic_cast<boost::exception const *>(se);
|
||||||
|
if( !se )
|
||||||
|
se=dynamic_cast<std::exception const *>(be);
|
||||||
#endif
|
#endif
|
||||||
char const * wh=0;
|
char const * wh=0;
|
||||||
if( with_what && se )
|
if( with_what && se )
|
||||||
@ -115,19 +140,12 @@ boost
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
inline
|
std::string
|
||||||
typename enable_if<exception_detail::enable_boost_exception_overload<T>,std::string>::type
|
|
||||||
diagnostic_information( T const & e )
|
diagnostic_information( T const & e )
|
||||||
{
|
{
|
||||||
return exception_detail::diagnostic_information_impl(&e,0,true);
|
boost::exception const * be=exception_detail::is_convertible_to_boost_exception<T>::value?((boost::exception const *)&e):0;
|
||||||
}
|
std::exception const * se=exception_detail::is_convertible_to_std_exception<T>::value?((std::exception const *)&e):0;
|
||||||
|
return exception_detail::diagnostic_information_impl(be,se,true);
|
||||||
template <class T>
|
|
||||||
inline
|
|
||||||
typename enable_if<exception_detail::enable_std_exception_overload<T>,std::string>::type
|
|
||||||
diagnostic_information( T const & e )
|
|
||||||
{
|
|
||||||
return exception_detail::diagnostic_information_impl(0,&e,true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
@ -152,40 +170,4 @@ boost
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BOOST_NO_EXCEPTIONS
|
|
||||||
#include <boost/exception/current_exception_cast.hpp>
|
|
||||||
namespace
|
|
||||||
boost
|
|
||||||
{
|
|
||||||
inline
|
|
||||||
std::string
|
|
||||||
current_exception_diagnostic_information()
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
else
|
|
||||||
return "No diagnostic information available.";
|
|
||||||
}
|
|
||||||
|
|
||||||
inline
|
|
||||||
std::string
|
|
||||||
diagnostic_information( exception_detail::exception_ptr_base const & p )
|
|
||||||
{
|
|
||||||
if( !p._empty() )
|
|
||||||
try
|
|
||||||
{
|
|
||||||
p._rethrow();
|
|
||||||
}
|
|
||||||
catch(
|
|
||||||
... )
|
|
||||||
{
|
|
||||||
return current_exception_diagnostic_information();
|
|
||||||
}
|
|
||||||
return "<empty>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -11,7 +11,18 @@
|
|||||||
#include <boost/detail/lightweight_test.hpp>
|
#include <boost/detail/lightweight_test.hpp>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
struct my_exception: boost::exception, std::exception { };
|
struct
|
||||||
|
my_exception:
|
||||||
|
boost::exception,
|
||||||
|
std::exception
|
||||||
|
{
|
||||||
|
char const *
|
||||||
|
what() const throw()
|
||||||
|
{
|
||||||
|
return "my_exception";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
typedef boost::error_info<struct my_tag,int> my_int;
|
typedef boost::error_info<struct my_tag,int> my_int;
|
||||||
|
|
||||||
bool called=false;
|
bool called=false;
|
||||||
|
Reference in New Issue
Block a user