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

Let exception_wrapper::handle, when empty, show the right error message

Summary:
[Folly] Let `exception_wrapper::handle`, when empty, show the right error message.

The error message currently says that `throw_exception` cannot be called on an empty `exception_wrapper`, but should say that `handle` cannot be called on an empty `exception_wrapper`.

Reviewed By: Orvid

Differential Revision: D5432380

fbshipit-source-id: ffa69c7675ee332e596e861e59ea273c39fc4717
parent b15db0d8
......@@ -459,7 +459,7 @@ inline bool exception_wrapper::is_compatible_with() const noexcept {
[[noreturn]] inline void exception_wrapper::throw_exception() const {
vptr_->throw_(this);
onNoExceptionError();
onNoExceptionError(__func__);
}
template <class CatchFn, bool IsConst>
......@@ -645,7 +645,7 @@ inline void exception_wrapper::handle(CatchFns... fns) {
using AllStdEx =
exception_wrapper_detail::AllOf<IsStdException, arg_type<CatchFns>...>;
if (!*this) {
onNoExceptionError();
onNoExceptionError(__func__);
}
this->handle_(AllStdEx{}, *this, fns...);
}
......@@ -654,7 +654,7 @@ inline void exception_wrapper::handle(CatchFns... fns) const {
using AllStdEx =
exception_wrapper_detail::AllOf<IsStdException, arg_type<CatchFns>...>;
if (!*this) {
onNoExceptionError();
onNoExceptionError(__func__);
}
this->handle_(AllStdEx{}, *this, fns...);
}
......
......@@ -76,11 +76,11 @@ exception_wrapper::exception_wrapper(std::exception_ptr ptr) noexcept
}
}
[[noreturn]] void exception_wrapper::onNoExceptionError() {
[[noreturn]] void exception_wrapper::onNoExceptionError(
char const* const name) {
std::ios_base::Init ioinit_; // ensure std::cerr is alive
std::cerr
<< "Cannot use `throw_exception` with an empty folly::exception_wrapper"
<< std::endl;
std::cerr << "Cannot use `" << name
<< "` with an empty folly::exception_wrapper" << std::endl;
std::terminate();
}
......
......@@ -197,7 +197,7 @@ class exception_wrapper final {
exception_wrapper (*get_exception_ptr_)(exception_wrapper const*);
};
[[noreturn]] static void onNoExceptionError();
[[noreturn]] static void onNoExceptionError(char const* name);
template <class Ret, class... Args>
static Ret noop_(Args...);
......
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