Commit 1891a99d authored by Shai Szulanski's avatar Shai Szulanski Committed by Facebook GitHub Bot

exception_wrapper::terminate_with

Summary: Enables terminating the process with the wrapped exception, as if calling folly::terminate_with polymorphically

Reviewed By: Gownta

Differential Revision: D32776269

fbshipit-source-id: d0d1ac374a38010bbe3ae608d22f7b2141d070e6
parent c4d6fcdd
......@@ -470,6 +470,9 @@ class exception_wrapper final {
//! \pre `bool(*this)`
[[noreturn]] void throw_exception() const;
//! Terminates the process with the wrapped expression.
[[noreturn]] void terminate_with() const noexcept { throw_exception(); }
//! Throws the wrapped expression nested into another exception.
//! \pre `bool(*this)`
//! \param ex Exception in *this will be thrown nested into ex;
......
......@@ -794,3 +794,9 @@ TEST(ExceptionWrapper, self_swap_test) {
auto& ew2 = ew;
ew = std::move(ew2); // should not crash
}
TEST(ExceptionWrapper, termiante_with_test) {
auto ew = make_exception_wrapper<int>(42);
EXPECT_DEATH(
try { ew.terminate_with(); } catch (...){}, "int");
}
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