then() ropagates exceptions properly
authorSam Merat <sammerat@fb.com>
Thu, 18 Jun 2015 18:42:07 +0000 (11:42 -0700)
committerSara Golemon <sgolemon@fb.com>
Fri, 19 Jun 2015 02:30:12 +0000 (19:30 -0700)
Summary: fixed then() exceptions propagation and added unit-test

Reviewed By: @fugalh

Differential Revision: D2159075

folly/futures/Future-inl.h
folly/futures/test/ThenTest.cpp

index 0d6679d8b49a4539f24e45cd0653e4bcc83eb37e..22816e91dd6fc537f5cf3762b941ec1627f326f3 100644 (file)
@@ -227,7 +227,7 @@ auto Future<T>::then(Executor* x, Arg&& arg, Args&&... args)
 
 template <class T>
 Future<void> Future<T>::then() {
-  return then([] (Try<T>&& t) {});
+  return then([] () {});
 }
 
 // onError where the callback returns T
index 6d330f64b6635a1bea4f94aa371e350be07cbae1..3264dded9a0d44f56802a391e67316699ba789f4 100644 (file)
@@ -168,3 +168,9 @@ TEST(Then, constValue) {
     });
   EXPECT_EQ(future.value(), 23);
 }
+
+TEST(Future, voidThenShouldPropagateExceptions) {
+  EXPECT_FALSE(makeFuture(42).then().hasException());
+  EXPECT_TRUE(makeFuture<int>(std::runtime_error("err"))
+             .then().hasException());
+}