Rename exception_wrapper::getExceptionPtr to to_exception_ptr
authorYedidya Feldblum <yfeldblum@fb.com>
Tue, 10 Jan 2017 04:30:42 +0000 (20:30 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Tue, 10 Jan 2017 04:33:15 +0000 (20:33 -0800)
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
folly/test/ExceptionWrapperTest.cpp

index 6bb39cc..f839af7 100644 (file)
@@ -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_;
     }
index 9f4c76e..4a4325a 100644 (file)
@@ -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);
 }