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

call future continuations after catch

Summary: Avoid calling arbitrary user code from within the scope of framework `catch` blocks. Instead, get the current exception in the catch block, save it, and call the user code after.

Differential Revision: D27842318

fbshipit-source-id: de3ebabc5c08332701a619a93b6e01bfccc0ea71
parent 7c86b9b4
......@@ -1908,6 +1908,7 @@ SemiFuture<T> unorderedReduceSemiFuture(It first, It last, T initial, F func) {
f.setCallback_([ctx, mp = std::move(p), mt = std::move(t)](
Executor::KeepAlive<>&&, Try<T>&& v) mutable {
if (v.hasValue()) {
exception_wrapper ew;
try {
Fulfill{}(
std::move(mp),
......@@ -1915,9 +1916,12 @@ SemiFuture<T> unorderedReduceSemiFuture(It first, It last, T initial, F func) {
std::move(v.value()),
mt.template get<IsTry::value, Arg&&>()));
} catch (std::exception& e) {
mp.setException(exception_wrapper(std::current_exception(), e));
ew = exception_wrapper{std::current_exception(), e};
} catch (...) {
mp.setException(exception_wrapper(std::current_exception()));
ew = exception_wrapper{std::current_exception()};
}
if (ew) {
mp.setException(std::move(ew));
}
} else {
mp.setTry(std::move(v));
......
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