forked from boostorg/exception
get_error_info returns raw pointer instead of shared_ptr (breaking change)
diagnostic_information can now be called with boost::exception or std::exception object. BOOST_THROW_EXCEPTION can now be used even if exceptions are disabled. added functions: current_exception_diagnostic_information, current_exception_cast documentation updated to match. [SVN r52225]
This commit is contained in:
@ -59,11 +59,11 @@ g()
|
||||
catch(
|
||||
my_error & x )
|
||||
{
|
||||
if( boost::shared_ptr<int const> err=boost::<span class="RenoLink"><a href="get_error_info.html">get_error_info</a></span><errno_info>(x) )
|
||||
if( int const * err=boost::<span class="RenoLink"><a href="get_error_info.html">get_error_info</a></span><errno_info>(x) )
|
||||
std::cerr << "Error code: " << *err;
|
||||
}
|
||||
}</pre>
|
||||
<p>The <span class="RenoLink"><a href="get_error_info.html">get_error_info</a></span> function template is instantiated with the typedef from (1), and is passed an exception object of a polymorphic type. If the exception object contains the requested value, the returned <span class="RenoLink"><a href="http://www.boost.org/libs/smart_ptr/shared_ptr.htm">shared_ptr</a></span> will point to it; otherwise an empty <span class="RenoLink"><a href="http://www.boost.org/libs/smart_ptr/shared_ptr.htm">shared_ptr</a></span> is returned.</p>
|
||||
<p>The <span class="RenoLink"><a href="get_error_info.html">get_error_info</a></span> function template is instantiated with the typedef from (1), and is passed an exception object of a polymorphic type. If the exception object contains the requested value, err will point to it; otherwise a null pointer is returned.</p>
|
||||
</div><div class="RenoIncludeDIV"><div class="RenoAutoDIV"><h3>Adding of Arbitrary Data to Active Exception Objects</h3>
|
||||
</div>
|
||||
<p>Sometimes the throw site does not have all the information that is needed at the catch site to make sense of what went wrong. Let's say we have an exception type file_read_error, which takes a file name in its constructor. Consider the following function:</p>
|
||||
|
Reference in New Issue
Block a user