1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>libsigc++ 2.0: exception_catch()</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#ffffff">
<table border="0" width="100%">
<tr>
<td width="10%" height="40"><img src="../../images/libsigc_logo.gif" alt="logo" border="0" width="100%" height="100%"/></td>
<td width="90%" height="40"><img src="../../images/top.gif" alt="top" width="100%" height="40"/></td>
</tr>
</table>
<center>
<a class="qindex" href="../../index.html">Main Page</a>
<a class="qindex" href="modules.html">Groups</a>
<a class="qindex" href="namespaces.html"> Namespaces</a>
</center>
<hr width="100%"/>
<!-- Generated by Doxygen 1.3.9.1 -->
<h1>exception_catch()<br>
<small>
[<a class="el" href="group__adaptors.html">Adaptors</a>]</small>
</h1><a class="el" href="namespacesigc.html#a31">sigc::exception_catch()</a> catches an exception thrown from within the wrapped functor and directs it to a catcher functor.
<a href="#_details">More...</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
</table>
This catcher can then rethrow the exception and catch it with the proper type.<p>
Note that the catcher is expected to return the same type as the wrapped functor so that normal flow can continue.<p>
Catchers can be cascaded to catch multiple types because uncaught rethrown exceptions proceed to the next catcher adaptor.<p>
<dl compact><dt><b>Examples:</b></dt><dd><div class="fragment"><pre class="fragment"> <span class="keyword">struct </span>my_catch
{
<span class="keywordtype">int</span> operator()()
{
<span class="keywordflow">try</span> { <span class="keywordflow">throw</span>; }
<span class="keywordflow">catch</span> (std::range_error e) <span class="comment">// catch what types we know</span>
{ std::cerr << <span class="stringliteral">"caught "</span> << e.what() << std::endl; }
<span class="keywordflow">return</span> 1;
}
}
<span class="keywordtype">int</span> foo(); <span class="comment">// throws std::range_error</span>
<a class="code" href="namespacesigc.html#a31">sigc::exception_catch</a>(&foo, my_catch())();
</pre></div></dd></dl>
The functor sigc::execption_catch() returns can be passed into <a class="el" href="classsigc_1_1signal7.html#a0">sigc::signal::connect()</a> directly.<p>
<dl compact><dt><b>Example:</b></dt><dd><div class="fragment"><pre class="fragment"> <a class="code" href="classsigc_1_1signal.html">sigc::signal<int></a> some_signal;
some_signal.<a class="code" href="classsigc_1_1signal7.html#a0">connect</a>(sigc::exception_catch(&foo, my_catch));
</pre></div></dd></dl>
<hr><address><small>
Generated for libsigc++ 2.0 by <a href="http://www.doxygen.org/index.html">
Doxygen</a> 1.3.9.1 © 1997-2001</small></address>
</body>
</html>
|