Commit fdc8edc2 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook GitHub Bot

let try_and_catch work with -fno-exceptions

Summary: The helper `catch_exception` may be used to wrap the `try {} catch (...) {}` syntax.

Reviewed By: Orvid, luciang

Differential Revision: D28276166

fbshipit-source-id: be903215251d8ea3321bd6d3b994b19359056f8c
parent 168d50be
......@@ -585,12 +585,8 @@ fbstring exceptionStr(exception_wrapper const& ew);
//! `exception_wrapper` with the thrown exception, if any.
template <typename F>
exception_wrapper try_and_catch(F&& fn) noexcept {
try {
static_cast<F&&>(fn)();
return exception_wrapper{};
} catch (...) {
return exception_wrapper{std::current_exception()};
}
auto x = [&] { return void(static_cast<F&&>(fn)()), std::exception_ptr{}; };
return exception_wrapper{catch_exception(x, std::current_exception)};
}
} // namespace folly
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment