]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/common/errorator: add unthrowable_wrapper::exception_ptr()
authorSamuel Just <sjust@redhat.com>
Sat, 1 Oct 2022 19:40:26 +0000 (12:40 -0700)
committerSamuel Just <sjust@redhat.com>
Sat, 1 Oct 2022 22:00:26 +0000 (15:00 -0700)
We need a way to get a representation that can be fed to
promise::set_exception.

Signed-off-by: Samuel Just <sjust@redhat.com>
src/crimson/common/errorator.h

index aee05f669157528411cb645094b747224483e51e..d9fae76120a90e703988cdd048528ad19fce9a21 100644 (file)
@@ -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<const ConcreteErrorT*>(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 <class ErrorVisitorT, class FuturatorT>
   friend class maybe_handle_error_t;
 
+protected:
+  std::exception_ptr to_exception_ptr() const {
+    const auto* concrete_error = static_cast<const ConcreteErrorT*>(this);
+    return concrete_error->to_exception_ptr();
+  }
+
 public:
   template <class Func>
   static decltype(auto) handle(Func&& func) {
@@ -127,6 +128,10 @@ struct unthrowable_wrapper : error_t<unthrowable_wrapper<ErrorT, ErrorV>> {
     return instance;
   }
 
+  static auto exception_ptr() {
+    return make().to_exception_ptr();
+  }
+
   template<class Func>
   static auto handle(Func&& func) {
     return [