return nullptr;
}
}
+} // namespace
+
+exception_wrapper exception_wrapper::from_exception_ptr(
+ std::exception_ptr const& ptr) noexcept {
+ if (!ptr) {
+ return exception_wrapper();
+ }
+ try {
+ std::rethrow_exception(ptr);
+ } catch (std::exception& e) {
+ return exception_wrapper(std::current_exception(), e);
+ } catch (...) {
+ return exception_wrapper(std::current_exception());
+ }
}
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 `throwException` with an empty folly::exception_wrapper"
- << std::endl;
+ std::cerr << "Cannot use `" << name
+ << "` with an empty folly::exception_wrapper" << std::endl;
std::terminate();
}
return ew.what();
}
-} // folly
+} // namespace folly