]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/common/errorator: consider return value as ready future in maybe_handle_error_t
authorKefu Chai <kchai@redhat.com>
Wed, 23 Jun 2021 08:11:24 +0000 (16:11 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 23 Jun 2021 08:13:58 +0000 (16:13 +0800)
this behavior mirrors seasetar::futurize::apply(), where non-future and
non-void return values are converted to future<>, and returned instead.
this change could simplify some use cases where we always return an
immediately available future.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/crimson/common/errorator.h

index 4a0f56a87d9bf56610e944fd2c21e1c33039446c..4b1369900366c33e5b05edc5cbc4c4602db207ad 100644 (file)
@@ -280,9 +280,9 @@ public:
         std::invoke(std::forward<ErrorVisitorT>(errfunc),
                     ErrorT::error_t::from_exception_ptr(std::move(ep)));
       } else {
-        static_assert(_impl::always_false<return_t>::value,
-                      "return of Error Visitor is not assignable to future");
-        // do nothing with `ep`.
+        result = FuturatorT::type::errorator_type::template make_ready_future<return_t>(
+          std::invoke(std::forward<ErrorVisitorT>(errfunc),
+                      ErrorT::error_t::from_exception_ptr(std::move(ep))));
       }
     }
   }