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
[[noreturn]] inline void exception_wrapper::throw_exception() const {
vptr_->throw_(this);
- onNoExceptionError();
+ onNoExceptionError(__func__);
}
template <class CatchFn, bool IsConst>
using AllStdEx =
exception_wrapper_detail::AllOf<IsStdException, arg_type<CatchFns>...>;
if (!*this) {
- onNoExceptionError();
+ onNoExceptionError(__func__);
}
this->handle_(AllStdEx{}, *this, fns...);
}
using AllStdEx =
exception_wrapper_detail::AllOf<IsStdException, arg_type<CatchFns>...>;
if (!*this) {
- onNoExceptionError();
+ onNoExceptionError(__func__);
}
this->handle_(AllStdEx{}, *this, fns...);
}
}
}
-[[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();
}
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...);