Commit fec7b1bc authored by Phil Willoughby's avatar Phil Willoughby Committed by Facebook Github Bot

Print why we called std::terminate

Summary:
When terminating because we were told to rethrow a nonexistent exception, we
now print that to `std::cerr` for the benefit of users on platforms which do not dump a stack trace on
`std::terminate`

Reviewed By: yfeldblum

Differential Revision: D4001087

fbshipit-source-id: 5b834cfc75bf42bec06a49ac9db55789a83df180
parent 1d2f2dcf
......@@ -18,6 +18,7 @@
#include <cassert>
#include <exception>
#include <iostream>
#include <memory>
#include <folly/ExceptionString.h>
#include <folly/detail/ExceptionWrapper.h>
......@@ -156,6 +157,9 @@ class exception_wrapper {
} else if (eptr_) {
std::rethrow_exception(eptr_);
}
std::cerr
<< "Cannot use `throwException` with an empty folly::exception_wrapper"
<< std::endl;
std::terminate();
}
......
......@@ -306,7 +306,7 @@ TEST(ExceptionWrapper, exceptionStr) {
TEST(ExceptionWrapper, throwException_noException) {
exception_wrapper ew;
ASSERT_DEATH(ew.throwException(), "exception");
ASSERT_DEATH(ew.throwException(), "empty folly::exception_wrapper");
}
namespace {
......
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