Wraps the return value from the lambda fn in a result, putting any thrown exception into its "error" state.
Declared in <folly/result/result.h>
template<
typename F,
typename RetF = decltype(FOLLY_DECLVAL(F&&)())>
conditional_t<is_instantiation_of_v<result, RetF>, RetF, result<RetF>>
result_catch_all(F&& fn) noexcept;
return result_catch_all(&{ return riskyWork(); });
Note:
result<> coroutines catch unhandled exceptions, but can additionally throw bad_alloc for coro frame allocations (but see LLVM PR 152623).
Like all functions, result<> non-coroutines let exceptions fly.
A result holding fn's return value, or its thrown exception.
| Name | Description |
|---|---|
| fn | The callable to invoke and wrap. |