From 372fad515345d453e340a01b54b2ded98a6f2f40 Mon Sep 17 00:00:00 2001 From: Sam Merat Date: Thu, 18 Jun 2015 11:42:07 -0700 Subject: [PATCH] then() ropagates exceptions properly Summary: fixed then() exceptions propagation and added unit-test Reviewed By: @fugalh Differential Revision: D2159075 --- folly/futures/Future-inl.h | 2 +- folly/futures/test/ThenTest.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/folly/futures/Future-inl.h b/folly/futures/Future-inl.h index 0d6679d8..22816e91 100644 --- a/folly/futures/Future-inl.h +++ b/folly/futures/Future-inl.h @@ -227,7 +227,7 @@ auto Future::then(Executor* x, Arg&& arg, Args&&... args) template Future Future::then() { - return then([] (Try&& t) {}); + return then([] () {}); } // onError where the callback returns T diff --git a/folly/futures/test/ThenTest.cpp b/folly/futures/test/ThenTest.cpp index 6d330f64..3264dded 100644 --- a/folly/futures/test/ThenTest.cpp +++ b/folly/futures/test/ThenTest.cpp @@ -168,3 +168,9 @@ TEST(Then, constValue) { }); EXPECT_EQ(future.value(), 23); } + +TEST(Future, voidThenShouldPropagateExceptions) { + EXPECT_FALSE(makeFuture(42).then().hasException()); + EXPECT_TRUE(makeFuture(std::runtime_error("err")) + .then().hasException()); +} -- 2.34.1