folly::detail::getTimekeeperSingleton()->after(dur)
.then([&,token](Try<void> const& t) {
if (token->exchange(true) == false) {
- try {
- t.value();
+ if (t.hasException()) {
+ p.setException(std::move(t.exception()));
+ } else {
p.setException(TimedOut());
- } catch (std::exception const& e) {
- p.setException(exception_wrapper(std::current_exception(), e));
- } catch (...) {
- p.setException(exception_wrapper(std::current_exception()));
}
baton.post();
}
tk->after(dur)
.then([ctx](Try<void> const& t) {
if (ctx->token.exchange(true) == false) {
- try {
- t.throwIfFailed();
+ if (t.hasException()) {
+ ctx->promise.setException(std::move(t.exception()));
+ } else {
ctx->promise.setException(std::move(ctx->exception));
- } catch (std::exception const& e2) {
- ctx->promise.setException(
- exception_wrapper(std::current_exception(), e2));
- } catch (...) {
- ctx->promise.setException(
- exception_wrapper(std::current_exception()));
}
}
});
return *e_;
}
+ const exception_wrapper& exception() const {
+ if (UNLIKELY(!hasException())) {
+ throw FutureException("exception(): Try does not contain an exception");
+ }
+ return *e_;
+ }
+
/*
* If the Try contains an exception and it is of type Ex, execute func(Ex)
*
return *e_;
}
+ const exception_wrapper& exception() const {
+ if (UNLIKELY(!hasException())) {
+ throw FutureException("exception(): Try does not contain an exception");
+ }
+ return *e_;
+ }
+
/*
* If the Try contains an exception and it is of type Ex, execute func(Ex)
*