Commit 372fad51 authored by Sam Merat's avatar Sam Merat Committed by Sara Golemon

then() ropagates exceptions properly

Summary: fixed then() exceptions propagation and added unit-test

Reviewed By: @fugalh

Differential Revision: D2159075
parent 86e0057c
...@@ -227,7 +227,7 @@ auto Future<T>::then(Executor* x, Arg&& arg, Args&&... args) ...@@ -227,7 +227,7 @@ auto Future<T>::then(Executor* x, Arg&& arg, Args&&... args)
template <class T> template <class T>
Future<void> Future<T>::then() { Future<void> Future<T>::then() {
return then([] (Try<T>&& t) {}); return then([] () {});
} }
// onError where the callback returns T // onError where the callback returns T
......
...@@ -168,3 +168,9 @@ TEST(Then, constValue) { ...@@ -168,3 +168,9 @@ TEST(Then, constValue) {
}); });
EXPECT_EQ(future.value(), 23); EXPECT_EQ(future.value(), 23);
} }
TEST(Future, voidThenShouldPropagateExceptions) {
EXPECT_FALSE(makeFuture(42).then().hasException());
EXPECT_TRUE(makeFuture<int>(std::runtime_error("err"))
.then().hasException());
}
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