From cd058f18c0331da9d2a20e5cc4c7d256af490508 Mon Sep 17 00:00:00 2001 From: Yedidya Feldblum Date: Mon, 9 Jan 2017 20:30:42 -0800 Subject: [PATCH] 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 --- folly/ExceptionWrapper.h | 2 +- folly/test/ExceptionWrapperTest.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) 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::forward(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( [=]() { 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( [=]() { 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); } -- 2.34.1