mirror of
https://github.com/boostorg/exception.git
synced 2025-07-12 20:16:34 +02:00
55 lines
2.4 KiB
HTML
55 lines
2.4 KiB
HTML
![]() |
<!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>Tutorial: Using enable_current_exception() at the Time of the Throw</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>
|
||
|
<div class="RenoIncludeDIV"><h3>Using enable_current_exception() at the Time of the Throw</h3>
|
||
|
<p>Here is how cloning can be enabled in a throw-expression (15.1):</p>
|
||
|
<pre>#include <<span class="RenoLink"><a href="exception_enable_exception_cloning_hpp.html">boost/exception/enable_current_exception.hpp</a></span>>
|
||
|
#include <<span class="RenoLink"><a href="exception_error_info_hpp.html">boost/exception/info.hpp</a></span>>
|
||
|
#include <stdio.h>
|
||
|
#include <errno.h>
|
||
|
|
||
|
typedef boost::error_info<struct tag_errno,int> errno_info;
|
||
|
|
||
|
class file_read_error: public boost::<span class="RenoLink"><a href="exception.html">exception</a></span> { };
|
||
|
|
||
|
void
|
||
|
file_read( FILE * f, void * buffer, size_t size )
|
||
|
{
|
||
|
if( size!=fread(buffer,1,size,f) )
|
||
|
throw boost::<span class="RenoLink"><a href="enable_current_exception.html">enable_current_exception</a></span>(file_read_error()) <<
|
||
|
errno_info(errno);
|
||
|
}</pre>
|
||
|
</div><h3>See also:</h3>
|
||
|
<div class="RenoPageList"><a href="cloning.html">Tutorial: Transporting of Exceptions between Threads<br/>
|
||
|
</a></div>
|
||
|
<div id="footer">
|
||
|
<p> </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>
|