Commit 51bad111 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook GitHub Bot

rethrow_current_exception

Summary: [Folly] `rethrow_current_exception`, a `-fno-exceptions` compatibility wrapper for `throw;`.

Reviewed By: ispeters

Differential Revision: D21656269

fbshipit-source-id: 8f37fe71c6255162b8f05268cae04ac5927013d7
parent 29e37140
......@@ -237,4 +237,17 @@ FOLLY_ERASE_TRYCATCH auto catch_exception(Try&& t, Catch&& c, CatchA&&... a) ->
#endif
}
/// rethrow_current_exception
///
/// Equivalent to:
///
/// throw;
[[noreturn]] FOLLY_ERASE void rethrow_current_exception() {
#if FOLLY_HAS_EXCEPTIONS
throw;
#else
std::terminate();
#endif
}
} // namespace folly
......@@ -115,3 +115,15 @@ TEST_F(ExceptionTest, catch_exception) {
EXPECT_EQ(4, folly::catch_exception(thrower(3), returner(4)));
EXPECT_EQ(3, folly::catch_exception<int>(thrower(3), identity));
}
TEST_F(ExceptionTest, rethrow_current_exception) {
EXPECT_THROW(
folly::invoke_noreturn_cold([] {
try {
throw std::runtime_error("bad");
} catch (...) {
folly::rethrow_current_exception();
}
}),
std::runtime_error);
}
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