<divclass="RenoIncludeDIV"><h3>Cloning and Re-throwing an Exception</h3>
<p>When you catch a <tt>boost::<spanclass="RenoLink"><ahref="exception.html">exception</a></span></tt>, you can call <tt><spanclass="RenoLink"><ahref="current_exception.html">current_exception</a></span>()</tt> to get an <tt><spanclass="RenoLink"><ahref="exception_ptr.html">exception_ptr</a></span></tt> object:</p>
<p>In the above example, note that <tt><spanclass="RenoLink"><ahref="current_exception.html">current_exception</a></span>()</tt> captures the original type of the exception object. The exception can be thrown again using the <tt><spanclass="RenoLink"><ahref="rethrow_exception.html">rethrow_exception</a></span>()</tt> function:</p>
<p><tt><spanclass="RenoLink"><ahref="current_exception.html">current_exception</a></span>()</tt> could fail to copy the original exception object in the following cases:</p>
<div><ul><li> if there is not enough memory, in which case the returned <tt><spanclass="RenoLink"><ahref="exception_ptr.html">exception_ptr</a></span></tt> points to an instance of <tt>std::bad_alloc</tt>, or</li>
<li> if <tt><spanclass="RenoLink"><ahref="enable_current_exception.html">enable_current_exception</a></span>()</tt> was not used in the throw-expression passed to the original <tt>throw</tt> statement and the current implementation does not have the necessary compiler-specific support to copy the exception automatically, in which case the returned <tt><spanclass="RenoLink"><ahref="exception_ptr.html">exception_ptr</a></span></tt> points to an instance of <tt><spanclass="RenoLink"><ahref="unknown_exception.html">unknown_exception</a></span></tt>.</li>
<p>Regardless, the use of <tt><spanclass="RenoLink"><ahref="current_exception.html">current_exception</a></span>()</tt> and <tt><spanclass="RenoLink"><ahref="rethrow_exception.html">rethrow_exception</a></span>()</tt> in the above examples is well-formed.</p>
</div><h3>See also:</h3>
<divclass="RenoPageList"><ahref="cloning.html">Tutorial: Transporting of Exceptions between Threads<br/>