Summary:
[Folly] Rename `exception_wrapper::getExceptionPtr` to `to_exception_ptr`.
Make it clear that this will sometimes be an expensive operation. Using the word `to` evokes the possibility of an expensive conversion, while using the word `get` implies cheap access.
Reviewed By: djwatson
Differential Revision:
D4391621
fbshipit-source-id:
33ca051d9be5a6050ba9f30b20faee35b7e58afb
return with_exception1<_t<std::decay<Ex>>>(std::forward<F>(f), this);
}
return with_exception1<_t<std::decay<Ex>>>(std::forward<F>(f), this);
}
- std::exception_ptr getExceptionPtr() const {
+ std::exception_ptr to_exception_ptr() const {
if (eptr_) {
return eptr_;
}
if (eptr_) {
return eptr_;
}
-TEST(ExceptionWrapper, getExceptionPtr_test) {
+TEST(ExceptionWrapper, get_or_make_exception_ptr_test) {
int expected = 23;
// This works, and doesn't slice.
exception_wrapper ew = try_and_catch<std::exception, std::runtime_error>(
[=]() { throw IntException(expected); });
int expected = 23;
// This works, and doesn't slice.
exception_wrapper ew = try_and_catch<std::exception, std::runtime_error>(
[=]() { throw IntException(expected); });
- std::exception_ptr eptr = ew.getExceptionPtr();
+ std::exception_ptr eptr = ew.to_exception_ptr();
EXPECT_THROW(std::rethrow_exception(eptr), IntException);
// I can try_and_catch a non-copyable base class. This will use
// std::exception_ptr internally.
exception_wrapper ew2 = try_and_catch<AbstractIntException>(
[=]() { throw IntException(expected); });
EXPECT_THROW(std::rethrow_exception(eptr), IntException);
// I can try_and_catch a non-copyable base class. This will use
// std::exception_ptr internally.
exception_wrapper ew2 = try_and_catch<AbstractIntException>(
[=]() { throw IntException(expected); });
- eptr = ew2.getExceptionPtr();
+ eptr = ew2.to_exception_ptr();
EXPECT_THROW(std::rethrow_exception(eptr), IntException);
// Test with const this.
const exception_wrapper& cew = ew;
EXPECT_THROW(std::rethrow_exception(eptr), IntException);
// Test with const this.
const exception_wrapper& cew = ew;
- eptr = cew.getExceptionPtr();
+ eptr = cew.to_exception_ptr();
EXPECT_THROW(std::rethrow_exception(eptr), IntException);
// Test with empty ew.
exception_wrapper empty_ew;
EXPECT_THROW(std::rethrow_exception(eptr), IntException);
// Test with empty ew.
exception_wrapper empty_ew;
- eptr = empty_ew.getExceptionPtr();
+ eptr = empty_ew.to_exception_ptr();