forked from boostorg/exception
documentation typos
[SVN r52124]
This commit is contained in:
@ -32,7 +32,7 @@ throw e;</pre>
|
|||||||
<p>and looks better than something like:</p>
|
<p>and looks better than something like:</p>
|
||||||
<pre>throw error().add(foo_info(foo)).add(bar_info(bar));</pre>
|
<pre>throw error().add(foo_info(foo)).add(bar_info(bar));</pre>
|
||||||
<h3>Why is boost::exception abstract?</h3>
|
<h3>Why is boost::exception abstract?</h3>
|
||||||
<p>To prevent exception-neutral contexts from erroneusly erasing the type of the original exception when adding <span class="RenoLink"><a href="error_info.html">error_info</a></span> to an active exception object:</p>
|
<p>To prevent exception-neutral contexts from erroneously erasing the type of the original exception when adding <span class="RenoLink"><a href="error_info.html">error_info</a></span> to an active exception object:</p>
|
||||||
<pre>catch( boost::<span class="RenoLink"><a href="exception.html">exception</a></span> & e )
|
<pre>catch( boost::<span class="RenoLink"><a href="exception.html">exception</a></span> & e )
|
||||||
{
|
{
|
||||||
e <span class="RenoLink"><a href="exception_operator_shl.html"><<</a></span> foo_info(foo);
|
e <span class="RenoLink"><a href="exception_operator_shl.html"><<</a></span> foo_info(foo);
|
||||||
|
@ -66,7 +66,7 @@ read_file( FILE * f, char const * name )
|
|||||||
</ul></div>
|
</ul></div>
|
||||||
<p>The second point is actually special case of violating the exception neutrality principle. Most contexts in a program can not handle exceptions; such contexts should not interfere with the process of exception handling.</p>
|
<p>The second point is actually special case of violating the exception neutrality principle. Most contexts in a program can not handle exceptions; such contexts should not interfere with the process of exception handling.</p>
|
||||||
<h3>The boost::exception solution</h3>
|
<h3>The boost::exception solution</h3>
|
||||||
<div><ul><li>Simply derive your exception types from boos::<span class="RenoLink"><a href="exception.html">exception</a></span>.</li>
|
<div><ul><li>Simply derive your exception types from boost::<span class="RenoLink"><a href="exception.html">exception</a></span>.</li>
|
||||||
<li>Confidently limit the throw site to provide only data that is available naturally.</li>
|
<li>Confidently limit the throw site to provide only data that is available naturally.</li>
|
||||||
<li>Use exception-neutral contexts between the throw and the catch to augment exceptions with more relevant data as they bubble up.</li>
|
<li>Use exception-neutral contexts between the throw and the catch to augment exceptions with more relevant data as they bubble up.</li>
|
||||||
</ul></div>
|
</ul></div>
|
||||||
@ -92,7 +92,7 @@ read_file( FILE * f )
|
|||||||
....
|
....
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if( FILE * fp=fopen(“foo.txt”,”rt”) )
|
if( FILE * fp=fopen("foo.txt","rt") )
|
||||||
{
|
{
|
||||||
shared_ptr<FILE> f(fp,fclose);
|
shared_ptr<FILE> f(fp,fclose);
|
||||||
....
|
....
|
||||||
@ -105,19 +105,19 @@ try
|
|||||||
}
|
}
|
||||||
catch( boost::<span class="RenoLink"><a href="exception.html">exception</a></span> & e )
|
catch( boost::<span class="RenoLink"><a href="exception.html">exception</a></span> & e )
|
||||||
{
|
{
|
||||||
e <span class="RenoLink"><a href="exception_operator_shl.html"><<</a></span> file_name(“foo.txt”);
|
e <span class="RenoLink"><a href="exception_operator_shl.html"><<</a></span> file_name("foo.txt");
|
||||||
throw;
|
throw;
|
||||||
}</pre>
|
}</pre>
|
||||||
<p>Finally here is how the handler retreives data from exceptions that derive from boost::<span class="RenoLink"><a href="exception.html">exception</a></span>:</p>
|
<p>Finally here is how the handler retreives data from exceptions that derive from boost::<span class="RenoLink"><a href="exception.html">exception</a></span>:</p>
|
||||||
<pre>catch( io_error & e )
|
<pre>catch( io_error & e )
|
||||||
{
|
{
|
||||||
std::cerr << “I/O Error!\n”;
|
std::cerr << "I/O Error!\n";
|
||||||
|
|
||||||
if( shared_ptr<std::string const> fn=<span class="RenoLink"><a href="get_error_info.html">get_error_info</a></span><file_name>(e) )
|
if( shared_ptr<std::string const> fn=<span class="RenoLink"><a href="get_error_info.html">get_error_info</a></span><file_name>(e) )
|
||||||
std::cerr << “File name: “ << *fn << “\n”;
|
std::cerr << "File name: " << *fn << "\n";
|
||||||
|
|
||||||
if( shared_ptr<int const> c=<span class="RenoLink"><a href="get_error_info.html">get_error_info</a></span><errno_code>(e) )
|
if( shared_ptr<int const> c=<span class="RenoLink"><a href="get_error_info.html">get_error_info</a></span><errno_code>(e) )
|
||||||
std::cerr << “OS says: “ << strerror(*c) << “\n”;
|
std::cerr << "OS says: " << strerror(*c) << "\n";
|
||||||
}</pre>
|
}</pre>
|
||||||
<p>In addition, boost::<span class="RenoLink"><a href="diagnostic_information.html">diagnostic_information</a></span> can be used to compose an automatic (if not user-friendly) message that contains all of the <span class="RenoLink"><a href="error_info.html">error_info</a></span> objects added to a boost::<span class="RenoLink"><a href="exception.html">exception</a></span>. This is useful for inclusion in logs and other diagnostic objects.</p>
|
<p>In addition, boost::<span class="RenoLink"><a href="diagnostic_information.html">diagnostic_information</a></span> can be used to compose an automatic (if not user-friendly) message that contains all of the <span class="RenoLink"><a href="error_info.html">error_info</a></span> objects added to a boost::<span class="RenoLink"><a href="exception.html">exception</a></span>. This is useful for inclusion in logs and other diagnostic objects.</p>
|
||||||
</div><div class="RenoAutoDIV"><div class="RenoHR"><hr/></div>
|
</div><div class="RenoAutoDIV"><div class="RenoHR"><hr/></div>
|
||||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user