try_throw_std_exception_from_error.html 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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>void try_throw_std_exception_from_error(std::error_code ec, const std::string &amp;msg = std::string{}) - 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/strong_swap.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="../../faq.html"><img src="../../images/next.png" alt="Next"></a></div><div id="content">
  12. <div class="titlepage"><div><div><h1 style="clear: both"><code>void try_throw_std_exception_from_error(std::error_code ec, const std::string &amp;msg = std::string{})</code></h1></div></div></div>
  13. <p>This function saves writing boilerplate by throwing a standard library exception
  14. type equivalent to the supplied error code, with an optional custom message.</p>
  15. <p>If the function returns, there is no standard library exception type equivalent
  16. to the supplied error code. The following codes produce the following exception
  17. throws:</p>
  18. <dl>
  19. <dt><code>EINVAL</code>
  20. <dd><code>std::invalid_argument</code>
  21. <dt><code>EDOM</code>
  22. <dd><code>std::domain_error</code>
  23. <dt><code>E2BIG</code>
  24. <dd><code>std::length_error</code>
  25. <dt><code>ERANGE</code>
  26. <dd><code>std::out_of_range</code>
  27. <dt><code>EOVERFLOW</code>
  28. <dd><code>std::overflow_error</code>
  29. <dt><code>ENOMEM</code>
  30. <dd><code>std::bad_alloc</code>
  31. </dl>
  32. <p>The choice to refer to POSIX <code>errno</code> values above reflects the matching algorithm.
  33. As
  34. <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>
  35. exactly maps POSIX <code>errno</code>, on all platforms
  36. <a href="https://en.cppreference.com/w/cpp/error/generic_category" class="api-reference" target="_blank"><i class="fa fa-book" aria-hidden="true"></i> <code>std::generic_category</code></a>
  37. error codes are matched by this function.
  38. Only on POSIX platforms only are
  39. <a href="https://en.cppreference.com/w/cpp/error/system_category" class="api-reference" target="_blank"><i class="fa fa-book" aria-hidden="true"></i> <code>std::system_category</code></a>
  40. error codes
  41. also matched by this function.</p>
  42. <p><em>Overridable</em>: Not overridable.</p>
  43. <p><em>Requires</em>: C++ exceptions to be globally enabled.</p>
  44. <p><em>Namespace</em>: <code>BOOST_OUTCOME_V2_NAMESPACE</code></p>
  45. <p><em>Header</em>: <code>&lt;boost/outcome/utils.hpp&gt;</code></p>
  46. </div><p><small>Last revised: February 01, 2019 at 23:42:52 UTC</small></p>
  47. <hr>
  48. <div class="spirit-nav">
  49. <a accesskey="p" href="../../reference/functions/strong_swap.html"><img src="../../images/prev.png" alt="Prev"></a>
  50. <a accesskey="u" href="../../reference/functions.html"><img src="../../images/up.png" alt="Up"></a>
  51. <a accesskey="h" href="../../index.html"><img src="../../images/home.png" alt="Home"></a><a accesskey="n" href="../../faq.html"><img src="../../images/next.png" alt="Next"></a></div></body>
  52. </html>