Compare commits

..

4 Commits

19 changed files with 5323 additions and 4174 deletions

23
CMakeLists.txt Normal file
View File

@ -0,0 +1,23 @@
#----------------------------------------------------------------------------
# This file was automatically generated from the original CMakeLists.txt file
# Add a variable to hold the headers for the library
set (lib_headers
exception.hpp
exception_ptr.hpp
exception
)
# Add a library target to the build system
boost_library_project(
exception
# SRCDIRS
TESTDIRS test
HEADERS ${lib_headers}
DOCDIRS doc
DESCRIPTION "A library for transporting of arbitrary data in exception objects, and transporting of exceptions between threads."
MODULARIZED
AUTHORS "Emil Dotchevski <emil -at- revergestudios.com>"
# MAINTAINERS
)

View File

@ -26,9 +26,9 @@
<p>Boost Exception also supports <span class="RenoLink"><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2179.html">N2179</a></span>-style <span class="RenoLink"><a href="tutorial_exception_ptr.html">copying</a></span> of exception objects, implemented non-intrusively and automatically by the boost::<span class="RenoLink"><a href="throw_exception.html">throw_exception</a></span> function.</p>
<h2>Contents</h2>
<div><ol><li>Tutorial<div><ol><li><span class="RenoLink"><a href="tutorial_transporting_data.html">Transporting of Arbitrary Data to the Catch Site</a></span></li>
<li><span class="RenoLink"><a href="tutorial_diagnostic_information.html">Diagnostic Information</a></span></li>
<li><span class="RenoLink"><a href="tutorial_enable_error_info.html">Integrating Boost Exception in Existing Exception Class Hierarchies</a></span></li>
<li><span class="RenoLink"><a href="tutorial_exception_ptr.html">Transporting of Exceptions Between Threads</a></span></li>
<li><span class="RenoLink"><a href="tutorial_diagnostic_information.html">Diagnostic Information</a></span></li>
</ol></div>
</li>
<li>Documentation<div><ol><li>Class <span class="RenoLink"><a href="exception.html">exception</a></span></li>
@ -95,9 +95,10 @@ boost
{
public:
typedef T value_type;
<span class="RenoIncludeSPAN"> typedef T <span class="RenoLink"><a href="error_info_value_type.html">value_type</a></span>;</span>
error_info( value_type const &amp; );
<span class="RenoIncludeSPAN"> <span class="RenoLink"><a href="error_info_error_info.html">error_info</a></span>( <span class="RenoLink"><a href="error_info_value_type.html">value_type</a></span> const &amp; v );</span>
<span class="RenoIncludeSPAN"> <span class="RenoLink"><a href="error_info_value_type.html">value_type</a></span> const &amp; <span class="RenoLink"><a href="error_info_value.html">value</a></span>() const;</span>
};</span>
<span class="RenoIncludeSPAN">template &lt;class E, class Tag, class T&gt;
@ -113,7 +114,7 @@ boost
<span class="RenoIncludeSPAN"> <span class="RenoIncludeSPAN">template &lt;class T&gt;
---unspecified--- <span class="RenoLink"><a href="enable_error_info.html">enable_error_info</a></span>( T const &amp; x );</span></span>
<span class="RenoIncludeSPAN"> <span class="RenoIncludeSPAN">std::string <span class="RenoLink"><a href="diagnostic_information.html">diagnostic_information</a></span>( boost::<span class="RenoLink"><a href="exception.html">exception</a></span> const &amp; x );</span></span>
<span class="RenoIncludeSPAN"> <span class="RenoIncludeSPAN">std::string <span class="RenoLink"><a href="diagnostic_information.html">diagnostic_information</a></span>( boost::<span class="RenoLink"><a href="exception.html">exception</a></span> const &amp; );</span></span>
<span class="RenoIncludeSPAN"> <span class="RenoIncludeSPAN">class
<span class="RenoLink"><a href="unknown_exception.html">unknown_exception</a></span>:
@ -191,9 +192,10 @@ boost
{
public:
typedef T value_type;
<span class="RenoIncludeSPAN"> typedef T <span class="RenoLink"><a href="error_info_value_type.html">value_type</a></span>;</span>
error_info( value_type const &amp; );
<span class="RenoIncludeSPAN"> <span class="RenoLink"><a href="error_info_error_info.html">error_info</a></span>( <span class="RenoLink"><a href="error_info_value_type.html">value_type</a></span> const &amp; v );</span>
<span class="RenoIncludeSPAN"> <span class="RenoLink"><a href="error_info_value_type.html">value_type</a></span> const &amp; <span class="RenoLink"><a href="error_info_value.html">value</a></span>() const;</span>
};</span>
}</pre>
</div><h4>Requirements:</h4>
@ -399,20 +401,32 @@ boost
<pre>namespace
boost
{
<span class="RenoIncludeSPAN"> std::string <span class="RenoLink"><a href="diagnostic_information.html">diagnostic_information</a></span>( boost::<span class="RenoLink"><a href="exception.html">exception</a></span> const &amp; x );</span>
<span class="RenoIncludeSPAN"> std::string <span class="RenoLink"><a href="diagnostic_information.html">diagnostic_information</a></span>( boost::<span class="RenoLink"><a href="exception.html">exception</a></span> const &amp; );</span>
}</pre>
</div><h4>Returns:</h4>
<p>This function iterates over all data 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&lt;&lt;</a></span>. The returned string is constructed by converting each data object to string and then concatenating these strings together.</p>
<p>When the <span class="RenoLink"><a href="error_info.html">error_info</a></span>&lt;Tag,T&gt; template is instantiated, the system attempts overload resolution for an unqualified call to to_string(x), where x is of type T. If this is successful, the to_string overload is expected to return std::string and is used to convert objects of type T to string.</p>
<p>Otherwise, the system attempts overload resolution for s &lt;&lt; x, where s is a std::ostringstream and x is of type T. If this is successful, the operator&lt;&lt; overload is used to convert objects of type T to string.</p>
<p>Otherwise the system is unable to convert objects of type T to string, and an unspecified stub string value is used without issuing a compile error.</p>
<p>This function returns a string value that is automatically composed from the string representations of all <span class="RenoLink"><a href="error_info.html">error_info</a></span> objects stored in a boost::<span class="RenoLink"><a href="exception.html">exception</a></span> through <span class="RenoLink"><a href="exception_operator_shl.html">operator&lt;&lt;</a></span>, along with other diagnostic information relevant to the exception.</p>
<p>The string representation of each <span class="RenoLink"><a href="error_info.html">error_info</a></span> object is deduced by a function call that is bound at the time the <span class="RenoLink"><a href="error_info.html">error_info</a></span>&lt;Tag,T&gt; template is instantiated. The following overload resolutions are attempted in order:</p>
<div><ol><li>Unqualified call to to_string(x), where x is of type <span class="RenoLink"><a href="error_info.html">error_info</a></span>&lt;Tag,T&gt; (the return value is expected to be of type std::string.)</li>
<li>Unqualified call to to_string(x.<span class="RenoLink"><a href="error_info_value.html">value</a></span>()) (the return value is expected to be of type std::string.)</li>
<li>Unqualified call to s &lt;&lt; x.<span class="RenoLink"><a href="error_info_value.html">value</a></span>(), where s is a std::ostringstream.</li>
</ol></div>
<p>The first successfully bound function is used at the time <span class="RenoLink"><a href="diagnostic_information.html">diagnostic_information</a></span> is called; if all 3 overload resolutions are unsuccessful, the system is unable to convert the <span class="RenoLink"><a href="error_info.html">error_info</a></span> object to string, and <i>an unspecified stub string value is used without issuing a compile error.</i></p>
<h4>Notes:</h4>
<div><ul><li>The format of the returned string is unspecified.</li>
<li>The returned string is <i>not</i> user-friendly.</li>
<li>If dynamic_cast&lt;std::exception const *&gt;(&amp;x) is not null, the returned string includes the output from std::exception::what.</li>
<li>The returned string may include additional platform-specific diagnostic information.</li>
</ul></div>
</div><h2>Throwing Exceptions</h2>
<div class="RenoIncludeDIV"><h4>Example:</h4>
<p>this is a possible output from the <span class="RenoLink"><a href="diagnostic_information.html">diagnostic_information</a></span> function, as used in <i>libs/exception/example/example_io.cpp:</i></p>
<pre>libs\exception\example\example_io.cpp(83): Throw in function class boost::shared_ptr&lt;struct _iobuf&gt; __cdecl my_fopen(const char *,const char *)
Dynamic exception type: class boost::exception_detail::clone_impl&lt;class fopen_error&gt;
std::exception::what: example_io error
[struct tag_errno *] = 2, OS says "No such file or directory"
[struct tag_file_name *] = tmp1.txt
[struct tag_function *] = fopen
[struct tag_open_mode *] = rb</pre>
</div></div><h2>Throwing Exceptions</h2>
<div class="RenoIncludeDIV"><div class="RenoAutoDIV"><h3>throw_exception</h3>
</div>
<div class="RenoIncludeDIV"><p><span class="RenoEscape">&#35;<!--<wiki>`&#35;</wiki>--></span>include &lt;<span class="RenoLink"><a href="throw_exception_hpp.html">boost/throw_exception.hpp</a></span>&gt;</p>

View File

@ -25,20 +25,32 @@
<pre>namespace
boost
{
<span class="RenoIncludeSPAN"> std::string <span class="RenoLink"><a href="diagnostic_information.html">diagnostic_information</a></span>( boost::<span class="RenoLink"><a href="exception.html">exception</a></span> const &amp; x );</span>
<span class="RenoIncludeSPAN"> std::string <span class="RenoLink"><a href="diagnostic_information.html">diagnostic_information</a></span>( boost::<span class="RenoLink"><a href="exception.html">exception</a></span> const &amp; );</span>
}</pre>
</div><h4>Returns:</h4>
<p>This function iterates over all data 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&lt;&lt;</a></span>. The returned string is constructed by converting each data object to string and then concatenating these strings together.</p>
<p>When the <span class="RenoLink"><a href="error_info.html">error_info</a></span>&lt;Tag,T&gt; template is instantiated, the system attempts overload resolution for an unqualified call to to_string(x), where x is of type T. If this is successful, the to_string overload is expected to return std::string and is used to convert objects of type T to string.</p>
<p>Otherwise, the system attempts overload resolution for s &lt;&lt; x, where s is a std::ostringstream and x is of type T. If this is successful, the operator&lt;&lt; overload is used to convert objects of type T to string.</p>
<p>Otherwise the system is unable to convert objects of type T to string, and an unspecified stub string value is used without issuing a compile error.</p>
<p>This function returns a string value that is automatically composed from the string representations of all <span class="RenoLink"><a href="error_info.html">error_info</a></span> objects stored in a boost::<span class="RenoLink"><a href="exception.html">exception</a></span> through <span class="RenoLink"><a href="exception_operator_shl.html">operator&lt;&lt;</a></span>, along with other diagnostic information relevant to the exception.</p>
<p>The string representation of each <span class="RenoLink"><a href="error_info.html">error_info</a></span> object is deduced by a function call that is bound at the time the <span class="RenoLink"><a href="error_info.html">error_info</a></span>&lt;Tag,T&gt; template is instantiated. The following overload resolutions are attempted in order:</p>
<div><ol><li>Unqualified call to to_string(x), where x is of type <span class="RenoLink"><a href="error_info.html">error_info</a></span>&lt;Tag,T&gt; (the return value is expected to be of type std::string.)</li>
<li>Unqualified call to to_string(x.<span class="RenoLink"><a href="error_info_value.html">value</a></span>()) (the return value is expected to be of type std::string.)</li>
<li>Unqualified call to s &lt;&lt; x.<span class="RenoLink"><a href="error_info_value.html">value</a></span>(), where s is a std::ostringstream.</li>
</ol></div>
<p>The first successfully bound function is used at the time <span class="RenoLink"><a href="diagnostic_information.html">diagnostic_information</a></span> is called; if all 3 overload resolutions are unsuccessful, the system is unable to convert the <span class="RenoLink"><a href="error_info.html">error_info</a></span> object to string, and <i>an unspecified stub string value is used without issuing a compile error.</i></p>
<h4>Notes:</h4>
<div><ul><li>The format of the returned string is unspecified.</li>
<li>The returned string is <i>not</i> user-friendly.</li>
<li>If dynamic_cast&lt;std::exception const *&gt;(&amp;x) is not null, the returned string includes the output from std::exception::what.</li>
<li>The returned string may include additional platform-specific diagnostic information.</li>
</ul></div>
</div><div class="RenoAutoDIV"><div class="RenoHR"><hr/></div>
<div class="RenoIncludeDIV"><h4>Example:</h4>
<p>this is a possible output from the <span class="RenoLink"><a href="diagnostic_information.html">diagnostic_information</a></span> function, as used in <i>libs/exception/example/example_io.cpp:</i></p>
<pre>libs\exception\example\example_io.cpp(83): Throw in function class boost::shared_ptr&lt;struct _iobuf&gt; __cdecl my_fopen(const char *,const char *)
Dynamic exception type: class boost::exception_detail::clone_impl&lt;class fopen_error&gt;
std::exception::what: example_io error
[struct tag_errno *] = 2, OS says "No such file or directory"
[struct tag_file_name *] = tmp1.txt
[struct tag_function *] = fopen
[struct tag_open_mode *] = rb</pre>
</div></div><div class="RenoAutoDIV"><div class="RenoHR"><hr/></div>
<h3>See Also:</h3>
<div class="RenoPageList"><a href="BOOST_THROW_EXCEPTION.html">BOOST_THROW_EXCEPTION<br/>
</a><a href="boost-exception.html">Boost Exception<br/>

View File

@ -31,9 +31,10 @@ boost
{
public:
typedef T value_type;
<span class="RenoIncludeSPAN"> typedef T <span class="RenoLink"><a href="error_info_value_type.html">value_type</a></span>;</span>
error_info( value_type const &amp; );
<span class="RenoIncludeSPAN"> <span class="RenoLink"><a href="error_info_error_info.html">error_info</a></span>( <span class="RenoLink"><a href="error_info_value_type.html">value_type</a></span> const &amp; v );</span>
<span class="RenoIncludeSPAN"> <span class="RenoLink"><a href="error_info_value_type.html">value_type</a></span> const &amp; <span class="RenoLink"><a href="error_info_value.html">value</a></span>() const;</span>
};</span>
}</pre>
</div><h4>Requirements:</h4>
@ -53,6 +54,9 @@ typedef boost::<span class="RenoLink"><a href="error_info.html">error_info</a></
</a><a href="exception_exception_hpp.html">boost/exception/exception.hpp<br/>
</a><a href="exception_error_info_hpp.html">boost/exception/info.hpp<br/>
</a><a href="diagnostic_information.html">diagnostic_information<br/>
</a><a href="error_info_error_info.html">error_info::error_info<br/>
</a><a href="error_info_value.html">error_info::value<br/>
</a><a href="error_info_value_type.html">error_info::value_type<br/>
</a><a href="exception.html">exception<br/>
</a><a href="exception_operator_shl.html">exception/operator&lt;&lt;<br/>
</a><a href="get_error_info.html">get_error_info<br/>

View File

@ -0,0 +1,52 @@
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
<title>error_info::error_info</title>
<link href='reno.css' type='text/css' rel='stylesheet'/>
</head>
<body>
<div class="body-0">
<div class="body-1">
<div class="body-2">
<div>
<div id="boost_logo">
<a href="http://www.boost.org"><img style="border:0" src="http://www.boost.org/boost.png" alt="Boost" width="277" height="86"/></a>
</div>
<h1>Boost Exception</h1>
</div>
<!-- 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) -->
<div class="RenoIncludeDIV"><div class="RenoAutoDIV"><h3>error_info::error_info</h3>
</div>
<div class="RenoIncludeDIV"><p><span class="RenoEscape">&#35;<!--<wiki>`&#35;</wiki>--></span>include &lt;<span class="RenoLink"><a href="exception_error_info_hpp.html">boost/exception/info.hpp</a></span>&gt;</p>
<pre><span class="RenoIncludeSPAN"><span class="RenoLink"><a href="error_info_error_info.html">error_info</a></span>( <span class="RenoLink"><a href="error_info_value_type.html">value_type</a></span> const &amp; v );</span></pre>
</div><h4>Effects:</h4>
<p>Stores a copy of v in the <span class="RenoLink"><a href="error_info.html">error_info</a></span> object.</p>
<div class="RenoIncludeDIV"><h4>Throws:</h4>
<p>Any exception emitted by v's copy constructor.</p>
</div></div><div class="RenoAutoDIV"><div class="RenoHR"><hr/></div>
<h3>See Also:</h3>
<div class="RenoPageList"><a href="error_info.html">error_info<br/>
</a></div>
</div>
<!-- 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) -->
<div id="footer">
<p>&nbsp;</p>
<hr/>
<p>
<a class="logo" href="http://jigsaw.w3.org/css-validator/validator?uri=http://revergestudios.com/boost-exception/reno.css"><img class="logo_pic" src="valid-css.png" alt="Valid CSS" height="31" width="88"/></a>
<a class="logo" href="http://validator.w3.org/check?uri=referer"><img class="logo_pic" src="valid-xhtml.png" alt="Valid XHTML 1.0" height="31" width="88"/></a>
<small>Copyright (c) 2006-2008 by Emil Dotchevski and Reverge Studios, Inc.<br/>
Distributed under the <a href="http://www.boost.org/LICENSE_1_0.txt">Boost Software License, Version 1.0</a>.</small>
</p>
</div>
</div>
</div>
</div>
</body>
</html>

53
doc/error_info_value.html Normal file
View File

@ -0,0 +1,53 @@
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
<title>error_info::value</title>
<link href='reno.css' type='text/css' rel='stylesheet'/>
</head>
<body>
<div class="body-0">
<div class="body-1">
<div class="body-2">
<div>
<div id="boost_logo">
<a href="http://www.boost.org"><img style="border:0" src="http://www.boost.org/boost.png" alt="Boost" width="277" height="86"/></a>
</div>
<h1>Boost Exception</h1>
</div>
<!-- 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) -->
<div class="RenoIncludeDIV"><div class="RenoAutoDIV"><h3>error_info::value</h3>
</div>
<div class="RenoIncludeDIV"><p><span class="RenoEscape">&#35;<!--<wiki>`&#35;</wiki>--></span>include &lt;<span class="RenoLink"><a href="exception_error_info_hpp.html">boost/exception/info.hpp</a></span>&gt;</p>
<pre><span class="RenoIncludeSPAN"><span class="RenoLink"><a href="error_info_value_type.html">value_type</a></span> const &amp; <span class="RenoLink"><a href="error_info_value.html">value</a></span>() const;</span></pre>
</div><h4>Description:</h4>
<p>Returns a const reference to the copy of the value passed to <span class="RenoLink"><a href="error_info.html">error_info</a></span>'s constructor stored in the <span class="RenoLink"><a href="error_info.html">error_info</a></span> object.</p>
<h4>Throws:</h4>
<p>Nothing.</p>
</div><div class="RenoAutoDIV"><div class="RenoHR"><hr/></div>
<h3>See Also:</h3>
<div class="RenoPageList"><a href="diagnostic_information.html">diagnostic_information<br/>
</a><a href="error_info.html">error_info<br/>
</a></div>
</div>
<!-- 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) -->
<div id="footer">
<p>&nbsp;</p>
<hr/>
<p>
<a class="logo" href="http://jigsaw.w3.org/css-validator/validator?uri=http://revergestudios.com/boost-exception/reno.css"><img class="logo_pic" src="valid-css.png" alt="Valid CSS" height="31" width="88"/></a>
<a class="logo" href="http://validator.w3.org/check?uri=referer"><img class="logo_pic" src="valid-xhtml.png" alt="Valid XHTML 1.0" height="31" width="88"/></a>
<small>Copyright (c) 2006-2008 by Emil Dotchevski and Reverge Studios, Inc.<br/>
Distributed under the <a href="http://www.boost.org/LICENSE_1_0.txt">Boost Software License, Version 1.0</a>.</small>
</p>
</div>
</div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,52 @@
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
<title>error_info::value_type</title>
<link href='reno.css' type='text/css' rel='stylesheet'/>
</head>
<body>
<div class="body-0">
<div class="body-1">
<div class="body-2">
<div>
<div id="boost_logo">
<a href="http://www.boost.org"><img style="border:0" src="http://www.boost.org/boost.png" alt="Boost" width="277" height="86"/></a>
</div>
<h1>Boost Exception</h1>
</div>
<!-- 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) -->
<div class="RenoIncludeDIV"><div class="RenoAutoDIV"><h3>error_info::value_type</h3>
</div>
<div class="RenoIncludeDIV"><p><span class="RenoEscape">&#35;<!--<wiki>`&#35;</wiki>--></span>include &lt;<span class="RenoLink"><a href="exception_error_info_hpp.html">boost/exception/info.hpp</a></span>&gt;</p>
<pre><span class="RenoIncludeSPAN">typedef T <span class="RenoLink"><a href="error_info_value_type.html">value_type</a></span>;</span></pre>
</div><h4>Definition:</h4>
<p>The expression <span class="RenoLink"><a href="error_info.html">error_info</a></span>&lt;Tag,T&gt;::<span class="RenoLink"><a href="error_info_value_type.html">value_type</a></span> evaluates to T.</p>
</div><div class="RenoAutoDIV"><div class="RenoHR"><hr/></div>
<h3>See Also:</h3>
<div class="RenoPageList"><a href="error_info.html">error_info<br/>
</a><a href="error_info_error_info.html">error_info::error_info<br/>
</a><a href="error_info_value.html">error_info::value<br/>
</a></div>
</div>
<!-- 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) -->
<div id="footer">
<p>&nbsp;</p>
<hr/>
<p>
<a class="logo" href="http://jigsaw.w3.org/css-validator/validator?uri=http://revergestudios.com/boost-exception/reno.css"><img class="logo_pic" src="valid-css.png" alt="Valid CSS" height="31" width="88"/></a>
<a class="logo" href="http://validator.w3.org/check?uri=referer"><img class="logo_pic" src="valid-xhtml.png" alt="Valid XHTML 1.0" height="31" width="88"/></a>
<small>Copyright (c) 2006-2008 by Emil Dotchevski and Reverge Studios, Inc.<br/>
Distributed under the <a href="http://www.boost.org/LICENSE_1_0.txt">Boost Software License, Version 1.0</a>.</small>
</p>
</div>
</div>
</div>
</div>
</body>
</html>

View File

@ -28,7 +28,7 @@ namespace
boost
{
<span class="RenoIncludeSPAN"> class <span class="RenoLink"><a href="exception.html">exception</a></span>;</span>
<span class="RenoIncludeSPAN"> <span class="RenoIncludeSPAN">std::string <span class="RenoLink"><a href="diagnostic_information.html">diagnostic_information</a></span>( boost::<span class="RenoLink"><a href="exception.html">exception</a></span> const &amp; x );</span></span>
<span class="RenoIncludeSPAN"> <span class="RenoIncludeSPAN">std::string <span class="RenoLink"><a href="diagnostic_information.html">diagnostic_information</a></span>( boost::<span class="RenoLink"><a href="exception.html">exception</a></span> const &amp; );</span></span>
}</pre>
</div></div><div class="RenoAutoDIV"><div class="RenoHR"><hr/></div>
<h3>See Also:</h3>

View File

@ -35,9 +35,10 @@ boost
{
public:
typedef T value_type;
<span class="RenoIncludeSPAN"> typedef T <span class="RenoLink"><a href="error_info_value_type.html">value_type</a></span>;</span>
error_info( value_type const &amp; );
<span class="RenoIncludeSPAN"> <span class="RenoLink"><a href="error_info_error_info.html">error_info</a></span>( <span class="RenoLink"><a href="error_info_value_type.html">value_type</a></span> const &amp; v );</span>
<span class="RenoIncludeSPAN"> <span class="RenoLink"><a href="error_info_value_type.html">value_type</a></span> const &amp; <span class="RenoLink"><a href="error_info_value.html">value</a></span>() const;</span>
};</span>
<span class="RenoIncludeSPAN">template &lt;class E, class Tag, class T&gt;
@ -48,6 +49,9 @@ boost
<div class="RenoPageList"><a href="boost-exception.html">Boost Exception<br/>
</a><a href="exception_hpp.html">boost/exception.hpp<br/>
</a><a href="error_info.html">error_info<br/>
</a><a href="error_info_error_info.html">error_info::error_info<br/>
</a><a href="error_info_value.html">error_info::value<br/>
</a><a href="error_info_value_type.html">error_info::value_type<br/>
</a><a href="exception_operator_shl.html">exception/operator&lt;&lt;<br/>
</a></div>
</div>

View File

@ -49,6 +49,9 @@
<p><a href="enable_current_exception.html">enable_current_exception</a></p>
<p><a href="enable_error_info.html">enable_error_info</a></p>
<p><a href="error_info.html">error_info</a></p>
<p><a href="error_info_error_info.html">error_info::error_info</a></p>
<p><a href="error_info_value.html">error_info::value</a></p>
<p><a href="error_info_value_type.html">error_info::value_type</a></p>
<p><a href="exception.html">exception</a></p>
<p><a href="exception_operator_shl.html">exception/operator&lt;&lt;</a></p>
<p><a href="exception_constructors.html">exception::exception</a></p>

File diff suppressed because it is too large Load Diff

View File

@ -45,7 +45,16 @@ g()
std::cerr &lt;&lt; <span class="RenoLink"><a href="diagnostic_information.html">diagnostic_information</a></span>(e);
}
}</pre>
</div><div class="RenoAutoDIV"><div class="RenoHR"><hr/></div>
<div class="RenoIncludeDIV"><h4>Example:</h4>
<p>this is a possible output from the <span class="RenoLink"><a href="diagnostic_information.html">diagnostic_information</a></span> function, as used in <i>libs/exception/example/example_io.cpp:</i></p>
<pre>libs\exception\example\example_io.cpp(83): Throw in function class boost::shared_ptr&lt;struct _iobuf&gt; __cdecl my_fopen(const char *,const char *)
Dynamic exception type: class boost::exception_detail::clone_impl&lt;class fopen_error&gt;
std::exception::what: example_io error
[struct tag_errno *] = 2, OS says "No such file or directory"
[struct tag_file_name *] = tmp1.txt
[struct tag_function *] = fopen
[struct tag_open_mode *] = rb</pre>
</div></div><div class="RenoAutoDIV"><div class="RenoHR"><hr/></div>
<h3>See Also:</h3>
<div class="RenoPageList"><a href="boost-exception.html">Boost Exception<br/>
</a></div>

View File

@ -62,41 +62,15 @@ g()
<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>
</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. Here is an example:</p>
<pre>#include &lt;stdio.h&gt;
#include &lt;string&gt;
class
file_read_error
{
public:
explicit
file_read_error( std::string const &amp; fn ):
fn_(fn)
{
};
std::string const &amp;
file_name() const
{
return fn_;
}
private:
std::string fn_;
};
void
<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>
<pre>void
file_read( FILE * f, void * buffer, size_t size )
{
if( size!=fread(buffer,1,size,f) )
throw file_read_error("????");
throw file_read_error(????);
}</pre>
<p>We have defined an exception class file_read_error which can store a file name, so that when we catch a file_read_error object, we know which file the failure is related to. However, the file_read function does not have the file name at the time of the throw; all it has is a FILE handle.</p>
<p>One possible solution is to not use FILE handles directly. We could have our own class file which stores both a FILE handle and a file name, and pass that to file_read. However, this could be problematic if we communicate with 3rd party code that does not use our class file (probably because they have their own similar class.)</p>
<p>A better solution is to make class file_read_error derive (possibly indirectly) from boost::<span class="RenoLink"><a href="exception.html">exception</a></span>, and free the file_read function from the burden of storing the file name in exceptions it throws:</p>
<p>How can the file_read function pass a file name to the exception type constructor? All it has is a FILE handle.</p>
<p>Using boost::<span class="RenoLink"><a href="exception.html">exception</a></span> allows us to free the file_read function from the burden of storing the file name in exceptions it throws:</p>
<pre>#include &lt;<span class="RenoLink"><a href="exception_hpp.html">boost/exception.hpp</a></span>&gt;
#include &lt;stdio.h&gt;
#include &lt;errno.h&gt;
@ -140,7 +114,6 @@ parse_file( char const * file_name )
}
}</pre>
<p>The above function is (almost) exception-neutral -- if an exception is emitted by any function call within the try block, parse_file does not need to do any real work, but it intercepts any boost::<span class="RenoLink"><a href="exception.html">exception</a></span> object, stores the file name, and re-throws using a throw-expression with no operand (15.1.6). The rationale for catching any boost::<span class="RenoLink"><a href="exception.html">exception</a></span> object is that the file name is relevant to any failure that occurs in parse_file, <i>even if the failure is unrelated to file I/O</i>.</p>
<p>As usual, the stored data can be retrieved using <span class="RenoLink"><a href="get_error_info.html">get_error_info</a></span>.</p>
</div><div class="RenoIncludeDIV"><div class="RenoAutoDIV"><h3>Adding Grouped Data to Exceptions</h3>
</div>
<p>The code snippet below demonstrates how boost::<span class="RenoLink"><a href="http://www.boost.org/libs/tuple/doc/tuple_users_guide.html">tuple</a></span> can be used to bundle the name of the function that failed, together with the reported errno so that they can be added to exception objects more conveniently together:</p>

View File

@ -19,6 +19,7 @@
#include <errno.h>
#include <string>
#include <iostream>
#include <sstream>
typedef boost::error_info<struct tag_errno,int> errno_info;
typedef boost::error_info<struct tag_file_stream,boost::weak_ptr<FILE> > file_stream_info;
@ -28,6 +29,15 @@ typedef boost::error_info<struct tag_file_name_src,std::string> file_name_src_in
typedef boost::error_info<struct tag_file_name_dst,std::string> file_name_dst_info; //The destination file name of a failed copy operation.
typedef boost::error_info<struct tag_function,std::string> function_info; //The name of the C function which reported the failure.
std::string
to_string( errno_info const & e )
{
int en=e.value();
std::ostringstream s;
s << en << ", OS says \"" << strerror(en) << "\"";
return s.str();
}
char const data[] = "example";
size_t const data_size = sizeof(data);

View File

@ -20,7 +20,7 @@ boost
struct
strwrap
{
std::string str;
std::string str;
char const * ptr;
explicit

View File

@ -15,6 +15,14 @@
namespace
boost
{
template <class Tag,class T>
inline
typename enable_if<has_to_string<T>,std::string>::type
to_string( error_info<Tag,T> const & x )
{
return to_string(x.value());
}
template <class Tag,class T>
inline
error_info<Tag,T>::
@ -45,7 +53,7 @@ boost
error_info<Tag,T>::
value_as_string() const
{
return to_string_stub(value_);
return to_string_stub(*this);
}
namespace

1
module.cmake Normal file
View File

@ -0,0 +1 @@
boost_module(exception DEPENDS smart_ptr detail utility tuple)

41
test/CMakeLists.txt Normal file
View File

@ -0,0 +1,41 @@
boost_additional_test_dependencies(exception BOOST_DEPENDS test)
boost_test_run(is_output_streamable_test)
boost_test_run(has_to_string_test)
boost_test_run(to_string_test)
boost_test_run(to_string_stub_test)
boost_test_compile_fail(to_string_fail)
#exception
boost_test_run(cloning_test)
boost_test_run(copy_exception_test)
boost_test_run(unknown_exception_test)
boost_test_run(exception_test)
#boost_test_run(boost_error_info_test)
boost_test_run(enable_error_info_test enable_error_info_test.cpp helper1.cpp)
boost_test_run(throw_exception_test throw_exception_test.cpp helper2.cpp)
boost_test_run(errno_test)
boost_test_run(error_info_test)
boost_test_run(diagnostic_information_test)
boost_test_compile_fail(exception_fail)
boost_test_compile_fail(throw_exception_fail)
# Compile headers tests
set (compile_tests
diagnostic_information_hpp_test
error_info_hpp_test
exception_ptr_hpp_test
exception_hpp_test
get_error_info_hpp_test
info_hpp_test
info_tuple_hpp_test
to_string_hpp_test
to_string_stub_hpp_test
)
#-- Create a Compile test for each source
foreach(test ${compile_tests})
boost_test_compile(${test} "${test}.cpp")
endforeach(test ${compile_tests})

View File

@ -9,10 +9,21 @@
#include <boost/detail/workaround.hpp>
#if BOOST_WORKAROUND(__CODEGEARC__, BOOST_TESTED_AT(0x610))
struct test_tag {};
struct test_tag1 {};
struct test_tag2 {};
#endif
typedef boost::error_info<struct test_tag,int> tag_int;
typedef boost::error_info<struct test_tag1,int> tagged_int1;
typedef boost::error_info<struct test_tag2,int> tagged_int2;
std::string
to_string( tagged_int2 const & x )
{
if( x.value()==42 )
return "fourty-two";
else
return "bad value";
}
struct
error1:
@ -38,19 +49,30 @@ main()
using namespace boost;
try
{
error1 x; x << tag_int(42);
error1 x; x << tagged_int1(42) << tagged_int2(42);
BOOST_TEST(x.what()==std::string("error1"));
throw x;
}
catch(
boost::exception & x )
{
std::string di=boost::diagnostic_information(x);
std::string di1=boost::diagnostic_information(x);
x << tagged_int1(2) << tagged_int2(2);
std::string di2 = diagnostic_information(x);
#ifndef BOOST_NO_RTTI
BOOST_TEST(di.find("type:")!=std::string::npos);
BOOST_TEST(di.find("error1")!=std::string::npos);
BOOST_TEST(di1.find("type:")!=std::string::npos);
BOOST_TEST(di1.find("error1")!=std::string::npos);
#endif
BOOST_TEST(di.find("test_tag")!=std::string::npos);
BOOST_TEST(di1.find("test_tag1")!=std::string::npos);
BOOST_TEST(di1.find("test_tag2")!=std::string::npos);
BOOST_TEST(di1.find("fourty-two")!=std::string::npos);
#ifndef BOOST_NO_RTTI
BOOST_TEST(di2.find("type:")!=std::string::npos);
BOOST_TEST(di2.find("error1")!=std::string::npos);
#endif
BOOST_TEST(di2.find("test_tag1")!=std::string::npos);
BOOST_TEST(di2.find("test_tag2")!=std::string::npos);
BOOST_TEST(di2.find("bad value")!=std::string::npos);
}
catch(
... )
@ -60,18 +82,22 @@ main()
try
{
error2 x;
x << tag_int(1);
x << tagged_int1(42) << tagged_int2(42);
throw x;
}
catch(
boost::exception & x )
{
std::string w1 = diagnostic_information(x);
x << tag_int(2);
std::string w2 = diagnostic_information(x);
BOOST_TEST( w1!=w2 );
BOOST_TEST(w1.find("test_tag")!=std::string::npos);
BOOST_TEST(w2.find("test_tag")!=std::string::npos);
std::string di1 = diagnostic_information(x);
x << tagged_int1(2) << tagged_int2(2);
std::string di2 = diagnostic_information(x);
BOOST_TEST( di1!=di2 );
BOOST_TEST(di1.find("test_tag1")!=std::string::npos);
BOOST_TEST(di1.find("test_tag2")!=std::string::npos);
BOOST_TEST(di1.find("fourty-two")!=std::string::npos);
BOOST_TEST(di2.find("test_tag1")!=std::string::npos);
BOOST_TEST(di2.find("test_tag2")!=std::string::npos);
BOOST_TEST(di2.find("bad value")!=std::string::npos);
}
catch(
... )