Commit d2efd810 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Casing consistency for exception_wrapper::throw_exception

Summary: [Folly] Casing consistency for `exception_wrapper::throw_exception`.

Reviewed By: Orvid

Differential Revision: D4944818

fbshipit-source-id: 72056fb24ab6362e9a0319f73b5bbf8c92d658ca
parent 7d06adb4
......@@ -383,7 +383,7 @@ inline bool exception_wrapper::is_compatible_with() const noexcept {
return with_exception([](Ex const&) {});
}
[[noreturn]] inline void exception_wrapper::throwException() const {
[[noreturn]] inline void exception_wrapper::throw_exception() const {
vptr_->throw_(this);
onNoExceptionError();
}
......@@ -498,7 +498,7 @@ inline void exception_wrapper::handle_(
bool handled = false;
auto impl = exception_wrapper_detail::fold(
HandleReduce<std::is_const<This>::value>{&handled},
[&] { this_.throwException(); },
[&] { this_.throw_exception(); },
fns...);
impl();
}
......
......@@ -79,7 +79,7 @@ exception_wrapper::exception_wrapper(std::exception_ptr ptr) noexcept
[[noreturn]] void exception_wrapper::onNoExceptionError() {
std::ios_base::Init ioinit_; // ensure std::cerr is alive
std::cerr
<< "Cannot use `throwException` with an empty folly::exception_wrapper"
<< "Cannot use `throw_exception` with an empty folly::exception_wrapper"
<< std::endl;
std::terminate();
}
......
......@@ -137,7 +137,7 @@ auto fold(Fn&& fn, A&& a, B&& b, Bs&&... bs) {
//! // Thread2: Exceptions are ok!
//! void processResult() {
//! try {
//! globalExceptionWrapper.throwException();
//! globalExceptionWrapper.throw_exception();
//! } catch (const FacePlantException& e) {
//! LOG(ERROR) << "FACEPLANT!";
//! } catch (const FailWhaleException& e) {
......@@ -499,7 +499,12 @@ class exception_wrapper final {
//! \pre `bool(*this)`
//! Throws the wrapped expression.
[[noreturn]] void throwException() const;
[[noreturn]] void throw_exception() const;
[[noreturn]] FOLLY_DEPRECATED(
"use throw_exception") void throwException() const {
throw_exception();
}
//! Call `fn` with the wrapped exception (if any), if `fn` can accept it.
//! \par Example
......@@ -542,7 +547,7 @@ class exception_wrapper final {
//! ew.handle(
//! [&](std::logic_error const& e) {
//! LOG(DFATAL) << "ruh roh";
//! ew.throwException(); // rethrow the active exception without
//! ew.throw_exception(); // rethrow the active exception without
//! // slicing it. Will not be caught by other
//! // handlers in this call.
//! },
......@@ -634,7 +639,7 @@ inline exception_wrapper try_and_catch_(F&& f) {
//!
//! \par Example Usage:
//! \code
//! // This catches my runtime_error and if I call throwException() on ew, it
//! // This catches my runtime_error and if I call throw_exception() on ew, it
//! // will throw a runtime_error
//! auto ew = folly::try_and_catch<std::exception, std::runtime_error>([=]() {
//! if (badThingHappens()) {
......@@ -642,7 +647,7 @@ inline exception_wrapper try_and_catch_(F&& f) {
//! }
//! });
//!
//! // This will catch the exception and if I call throwException() on ew, it
//! // This will catch the exception and if I call throw_exception() on ew, it
//! // will throw a std::exception
//! auto ew = folly::try_and_catch<std::exception, std::runtime_error>([=]() {
//! if (badThingHappens()) {
......
......@@ -122,7 +122,7 @@ template <class T>
void Try<T>::throwIfFailed() const {
if (contains_ != Contains::VALUE) {
if (contains_ == Contains::EXCEPTION) {
e_->throwException();
e_->throw_exception();
} else {
throw UsingUninitializedTry();
}
......@@ -131,7 +131,7 @@ void Try<T>::throwIfFailed() const {
void Try<void>::throwIfFailed() const {
if (!hasValue_) {
e_->throwException();
e_->throw_exception();
}
}
......
......@@ -25,7 +25,7 @@ TEST(Interrupt, raise) {
using eggs_t = std::runtime_error;
Promise<Unit> p;
p.setInterruptHandler([&](const exception_wrapper& e) {
EXPECT_THROW(e.throwException(), eggs_t);
EXPECT_THROW(e.throw_exception(), eggs_t);
});
p.getFuture().raise(eggs_t("eggs"));
}
......@@ -33,7 +33,7 @@ TEST(Interrupt, raise) {
TEST(Interrupt, cancel) {
Promise<Unit> p;
p.setInterruptHandler([&](const exception_wrapper& e) {
EXPECT_THROW(e.throwException(), FutureCancellation);
EXPECT_THROW(e.throw_exception(), FutureCancellation);
});
p.getFuture().cancel();
}
......
......@@ -2,7 +2,7 @@ from libcpp cimport bool as cbool
cdef extern from "folly/ExceptionWrapper.h" namespace "folly":
cdef cppclass cFollyExceptionWrapper "folly::exception_wrapper":
void throwException() except +
void throw_exception() except +
cdef extern from "folly/Try.h" namespace "folly" nogil:
cdef cppclass cFollyTry "folly::Try"[T]:
......
......@@ -24,7 +24,7 @@ cdef void handle_uint64_t(cFollyTry[uint64_t]&& res, PyObject* userData):
future = <object> userData
if res.hasException():
try:
res.exception().throwException()
res.exception().throw_exception()
except Exception as ex:
future.set_exception(ex)
else:
......
......@@ -119,7 +119,7 @@ BENCHMARK_RELATIVE(exception_wrapper_create_and_throw, iters) {
for (size_t i = 0; i < iters; ++i) {
auto ew = folly::make_exception_wrapper<std::runtime_error>(e);
try {
ew.throwException();
ew.throw_exception();
} catch (std::runtime_error&) {
}
}
......@@ -172,7 +172,7 @@ BENCHMARK_RELATIVE(exception_wrapper_create_and_throw_concurrent, iters) {
for (size_t i = 0; i < iters; ++i) {
auto ew = folly::make_exception_wrapper<std::runtime_error>(e);
try {
ew.throwException();
ew.throw_exception();
} catch (std::runtime_error&) {
}
}
......
......@@ -61,7 +61,7 @@ T& from_eptr(std::exception_ptr& eptr) {
}
}
// Tests that when we call throwException, the proper type is thrown (derived)
// Tests that when we call throw_exception, the proper type is thrown (derived)
TEST(ExceptionWrapper, throw_test) {
std::runtime_error e("payload");
auto ew = make_exception_wrapper<std::runtime_error>(e);
......@@ -70,7 +70,7 @@ TEST(ExceptionWrapper, throw_test) {
container.push_back(ew);
try {
container[0].throwException();
container[0].throw_exception();
} catch (std::runtime_error& err) {
std::string expected = "payload";
std::string actual = err.what();
......@@ -222,7 +222,7 @@ TEST(ExceptionWrapper, with_exception_ptr_empty) {
EXPECT_EQ("", ew.what());
EXPECT_FALSE(ew.is_compatible_with<std::exception>());
EXPECT_FALSE(ew.is_compatible_with<int>());
EXPECT_DEATH(ew.throwException(), "empty folly::exception_wrapper");
EXPECT_DEATH(ew.throw_exception(), "empty folly::exception_wrapper");
}
TEST(ExceptionWrapper, with_shared_ptr_test) {
......@@ -238,7 +238,7 @@ TEST(ExceptionWrapper, with_shared_ptr_test) {
EXPECT_TRUE(ew.is_compatible_with<std::exception>());
EXPECT_TRUE(ew.is_compatible_with<std::runtime_error>());
EXPECT_FALSE(ew.is_compatible_with<int>());
EXPECT_THROW(ew.throwException(), std::runtime_error);
EXPECT_THROW(ew.throw_exception(), std::runtime_error);
exception_wrapper(std::move(ew));
EXPECT_FALSE(bool(ew));
......@@ -266,7 +266,7 @@ TEST(ExceptionWrapper, with_exception_ptr_exn_test) {
EXPECT_TRUE(ew.is_compatible_with<std::exception>());
EXPECT_TRUE(ew.is_compatible_with<std::runtime_error>());
EXPECT_FALSE(ew.is_compatible_with<int>());
EXPECT_THROW(ew.throwException(), std::runtime_error);
EXPECT_THROW(ew.throw_exception(), std::runtime_error);
exception_wrapper(std::move(ew));
EXPECT_FALSE(bool(ew));
......@@ -293,7 +293,7 @@ TEST(ExceptionWrapper, with_exception_ptr_any_test) {
EXPECT_FALSE(ew.is_compatible_with<std::exception>());
EXPECT_FALSE(ew.is_compatible_with<std::runtime_error>());
EXPECT_TRUE(ew.is_compatible_with<int>());
EXPECT_THROW(ew.throwException(), int);
EXPECT_THROW(ew.throw_exception(), int);
exception_wrapper(std::move(ew));
EXPECT_FALSE(bool(ew));
......@@ -321,7 +321,7 @@ TEST(ExceptionWrapper, with_non_std_exception_test) {
EXPECT_FALSE(ew.is_compatible_with<std::exception>());
EXPECT_FALSE(ew.is_compatible_with<std::runtime_error>());
EXPECT_TRUE(ew.is_compatible_with<int>());
EXPECT_THROW(ew.throwException(), int);
EXPECT_THROW(ew.throw_exception(), int);
exception_wrapper(std::move(ew));
EXPECT_FALSE(bool(ew));
......@@ -347,7 +347,7 @@ TEST(ExceptionWrapper, with_exception_ptr_any_nil_test) {
EXPECT_FALSE(ew.is_compatible_with<std::exception>());
EXPECT_FALSE(ew.is_compatible_with<std::runtime_error>());
EXPECT_TRUE(ew.is_compatible_with<int>());
EXPECT_THROW(ew.throwException(), int);
EXPECT_THROW(ew.throw_exception(), int);
exception_wrapper(std::move(ew));
EXPECT_FALSE(bool(ew));
......@@ -415,7 +415,7 @@ TEST(ExceptionWrapper, non_std_exception_test) {
// non-std::exception types are supported, but the only way to
// access their value is to explicity rethrow and catch it.
try {
ew.throwException();
ew.throw_exception();
} catch /* nolint */ (int& i) {
EXPECT_EQ(i, expected);
}
......@@ -429,13 +429,13 @@ TEST(ExceptionWrapper, exceptionStr) {
TEST(ExceptionWrapper, throwException_noException) {
exception_wrapper ew;
ASSERT_DEATH(ew.throwException(), "empty folly::exception_wrapper");
ASSERT_DEATH(ew.throw_exception(), "empty folly::exception_wrapper");
}
namespace {
class TestException : public std::exception { };
void testEW(const exception_wrapper& ew) {
EXPECT_THROW(ew.throwException(), TestException);
EXPECT_THROW(ew.throw_exception(), TestException);
}
} // 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