Commit 32fc2d57 authored by James Sedgwick's avatar James Sedgwick Committed by woo

kill a couple unnecessary rethrows

Summary: as above, there were less of these than I expected, nice

Test Plan: unit

Reviewed By: hans@fb.com

Subscribers: trunkagent, folly-diffs@, jsedgwick

FB internal diff: D1789332

Tasks: 5949939

Signature: t1:1789332:1421878033:d7c2979a77b51a5257b8bcd910ad9296ca1aa7e0
parent 5d8f3bce
......@@ -535,13 +535,10 @@ namespace {
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();
}
......@@ -627,15 +624,10 @@ Future<T> Future<T>::within(Duration dur, E e, Timekeeper* tk) {
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()));
}
}
});
......
......@@ -183,6 +183,13 @@ class Try {
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)
*
......@@ -295,6 +302,13 @@ class Try<void> {
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)
*
......
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