error_from_exception.html 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  3. <title>std::error_code error_from_exception(std::exception_ptr &amp;&amp;ep = std::current_exception(), std::error_code not_matched = std::make_error_code(std::errc::resource_unavailable_try_again)) noexcept - Boost.Outcome documentation</title>
  4. <link rel="stylesheet" href="../../css/boost.css" type="text/css">
  5. <meta name="generator" content="Hugo 0.52 with Boostdoc theme">
  6. <meta name="viewport" content="width=device-width,initial-scale=1.0"/>
  7. <link rel="icon" href="../../images/favicon.ico" type="image/ico"/>
  8. <body><div class="spirit-nav">
  9. <a accesskey="p" href="../../reference/functions/try_operation_return_as.html"><img src="../../images/prev.png" alt="Prev"></a>
  10. <a accesskey="u" href="../../reference/functions.html"><img src="../../images/up.png" alt="Up"></a>
  11. <a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="../../reference/functions/strong_swap.html"><img src="../../images/next.png" alt="Next"></a></div><div id="content">
  12. <div class="titlepage"><div><div><h1 style="clear: both"><code>std::error_code error_from_exception(std::exception_ptr &amp;&amp;ep = std::current_exception(), std::error_code not_matched = std::make_error_code(std::errc::resource_unavailable_try_again)) noexcept</code></h1></div></div></div>
  13. <p>This function saves writing boilerplate by rethrowing <code>ep</code> within a <code>try</code>
  14. block, with a long sequence of <code>catch()</code> handlers, one for every standard
  15. C++ exception type which has a near or exact equivalent code in
  16. <a href="https://en.cppreference.com/w/cpp/error/errc" class="api-reference" target="_blank"><i class="fa fa-book" aria-hidden="true"></i> <code>std::errc</code></a>
  17. .</p>
  18. <p>If matched, <code>ep</code> is set to a default constructed
  19. <a href="https://en.cppreference.com/w/cpp/error/exception_ptr" class="api-reference" target="_blank"><i class="fa fa-book" aria-hidden="true"></i> <code>std::exception_ptr</code></a>
  20. ,
  21. and a
  22. <a href="https://en.cppreference.com/w/cpp/error/error_code" class="api-reference" target="_blank"><i class="fa fa-book" aria-hidden="true"></i> <code>std::error_code</code></a>
  23. is constructed using the ADL discovered free
  24. function <code>make_error_code()</code> upon the <code>std::errc</code> enumeration value matching the
  25. thrown exception.</p>
  26. <p>If not matched, <code>ep</code> is left intact, and the <code>not_matched</code> error code supplied
  27. is returned instead.</p>
  28. <p><em>Overridable</em>: Not overridable.</p>
  29. <p><em>Requires</em>: C++ exceptions to be globally enabled.</p>
  30. <p><em>Namespace</em>: <code>BOOST_OUTCOME_V2_NAMESPACE</code></p>
  31. <p><em>Header</em>: <code>&lt;boost/outcome/utils.hpp&gt;</code></p>
  32. </div><p><small>Last revised: February 01, 2019 at 23:42:52 UTC</small></p>
  33. <hr>
  34. <div class="spirit-nav">
  35. <a accesskey="p" href="../../reference/functions/try_operation_return_as.html"><img src="../../images/prev.png" alt="Prev"></a>
  36. <a accesskey="u" href="../../reference/functions.html"><img src="../../images/up.png" alt="Up"></a>
  37. <a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="../../reference/functions/strong_swap.html"><img src="../../images/next.png" alt="Next"></a></div></body>
  38. </html>