Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

Prev Up HomeNext

std::error_code error_from_exception(std::exception_ptr &&ep = std::current_exception(), std::error_code not_matched = std::make_error_code(std::errc::resource_unavailable_try_again)) noexcept

This function saves writing boilerplate by rethrowing ep within a try block, with a long sequence of catch() handlers, one for every standard C++ exception type which has a near or exact equivalent code in std::errc .

If matched, ep is set to a default constructed std::exception_ptr , and a std::error_code is constructed using the ADL discovered free function make_error_code() upon the std::errc enumeration value matching the thrown exception.

If not matched, ep is left intact, and the not_matched error code supplied is returned instead.

Overridable: Not overridable.

Requires: C++ exceptions to be globally enabled.

Namespace: BOOST_OUTCOME_V2_NAMESPACE

Header: <boost/outcome/utils.hpp>

Last revised: February 01, 2019 at 23:42:52 UTC


Prev Up HomeNext