From: Yedidya Feldblum <yfeldblum@fb.com> Date: Tue, 10 Jan 2017 04:30:42 +0000 (-0800) Subject: Rename exception_wrapper::getExceptionPtr to to_exception_ptr X-Git-Tag: v2017.03.06.00~110 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=cd058f18c0331da9d2a20e5cc4c7d256af490508;p=folly.git Rename exception_wrapper::getExceptionPtr to to_exception_ptr 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 --- diff --git a/folly/ExceptionWrapper.h b/folly/ExceptionWrapper.h index 6bb39ccc..f839af7d 100644 --- a/folly/ExceptionWrapper.h +++ b/folly/ExceptionWrapper.h @@ -222,7 +222,7 @@ class exception_wrapper { 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_; } diff --git a/folly/test/ExceptionWrapperTest.cpp b/folly/test/ExceptionWrapperTest.cpp index 9f4c76ed..4a4325a6 100644 --- a/folly/test/ExceptionWrapperTest.cpp +++ b/folly/test/ExceptionWrapperTest.cpp @@ -208,30 +208,30 @@ TEST(ExceptionWrapper, with_exception_test) { */ } -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); }); - 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); }); - eptr = ew2.getExceptionPtr(); + eptr = ew2.to_exception_ptr(); 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; - eptr = empty_ew.getExceptionPtr(); + eptr = empty_ew.to_exception_ptr(); EXPECT_FALSE(eptr); }