void try_throw_std_exception_from_error(std::error_code ec, const std::string &msg = std::string{})
This function saves writing boilerplate by throwing a standard library exception type equivalent to the supplied error code, with an optional custom message.
If the function returns, there is no standard library exception type equivalent to the supplied error code. The following codes produce the following exception throws:
EINVALstd::invalid_argumentEDOMstd::domain_errorE2BIGstd::length_errorERANGEstd::out_of_rangeEOVERFLOWstd::overflow_errorENOMEMstd::bad_alloc
The choice to refer to POSIX errno values above reflects the matching algorithm.
As
std::errc exactly maps POSIX errno, on all platforms
std::generic_category error codes are matched by this function.
Only on POSIX platforms only are
std::system_category error codes
also matched by this function.
Overridable: Not overridable.
Requires: C++ exceptions to be globally enabled.
Namespace: BOOST_OUTCOME_V2_NAMESPACE
Header: <boost/outcome/utils.hpp>



