From: Samuel Just Date: Sat, 1 Oct 2022 19:40:26 +0000 (-0700) Subject: crimson/common/errorator: add unthrowable_wrapper::exception_ptr() X-Git-Tag: v18.1.0~1069^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=99ea1e0d0002f6fe9a91a6291ec23766d0a419f9;p=ceph.git crimson/common/errorator: add unthrowable_wrapper::exception_ptr() We need a way to get a representation that can be fed to promise::set_exception. Signed-off-by: Samuel Just --- diff --git a/src/crimson/common/errorator.h b/src/crimson/common/errorator.h index aee05f669157..d9fae76120a9 100644 --- a/src/crimson/common/errorator.h +++ b/src/crimson/common/errorator.h @@ -93,11 +93,6 @@ class error_t { return ConcreteErrorT::exception_ptr_type_info(); } - std::exception_ptr to_exception_ptr() const { - const auto* concrete_error = static_cast(this); - return concrete_error->to_exception_ptr(); - } - decltype(auto) static from_exception_ptr(std::exception_ptr ep) { return ConcreteErrorT::from_exception_ptr(std::move(ep)); } @@ -108,6 +103,12 @@ class error_t { template friend class maybe_handle_error_t; +protected: + std::exception_ptr to_exception_ptr() const { + const auto* concrete_error = static_cast(this); + return concrete_error->to_exception_ptr(); + } + public: template static decltype(auto) handle(Func&& func) { @@ -127,6 +128,10 @@ struct unthrowable_wrapper : error_t> { return instance; } + static auto exception_ptr() { + return make().to_exception_ptr(); + } + template static auto handle(Func&& func) { return [