folly::catch_exception

catch_exception overloads

Synopses

Declared in <folly/lang/Exception.h>

Usage note: Passing extra values as arguments rather than capturing them allows smaller inlined native code at the call-site.

template<
    typename Try,
    typename Catch,
    typename... CatchA,
    typename R = std::common_type_t<decltype(FOLLY_DECLVAL(Try&&)()), decltype(FOLLY_DECLVAL(Catch&&)(FOLLY_DECLVAL(CatchA&&)...))>>
R
catch_exception(
    Try&& t,
    Catch&& c,
    CatchA&&... a) noexcept(/* see-below */);
» more...

catch_exception

template<
    typename E,
    typename Try,
    typename Catch,
    typename... CatchA,
    typename R = std::common_type_t<decltype(FOLLY_DECLVAL(Try&&)()), decltype(FOLLY_DECLVAL(Catch&&)(
            FOLLY_DECLVAL(E&), FOLLY_DECLVAL(CatchA&&)...))>>
R
catch_exception(
    Try&& t,
    Catch&& c,
    CatchA&&... a);
» more...

Return Value

  • The result of t, or of c when an exception is caught.
  • The result of t, or of c when an exception of type E is caught.

Parameters

NameDescription
tThe function to invoke and guard against a thrown exception.
cThe handler invoked when any exception is caught.
aThe extra arguments forwarded to the handler.