]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/common/errorator: cleanup ErrorT::handler call
authorMatan Breizman <mbreizma@redhat.com>
Mon, 21 Apr 2025 14:13:34 +0000 (14:13 +0000)
committerMatan Breizman <mbreizma@redhat.com>
Tue, 22 Apr 2025 15:11:58 +0000 (15:11 +0000)
call error_t::handle without decalring handler and invoking it later on

Signed-off-by: Matan Breizman <mbreizma@redhat.com>
src/crimson/common/errorator.h

index e7c1684e5becb5471a154a0378ee653b3878a255..47ef83125fa36ccc62608e557a9d641a5385fc36 100644 (file)
@@ -930,10 +930,8 @@ private:
     template <typename ErrorT, EnableIf<ErrorT>...>
     decltype(auto) operator()(ErrorT&& e) {
       using decayed_t = std::decay_t<decltype(e)>;
-      auto&& handler =
-        decayed_t::error_t::handle(std::forward<ErrorFunc>(func));
-      static_assert(std::is_invocable_v<decltype(handler), ErrorT>);
-      return std::invoke(std::move(handler), std::forward<ErrorT>(e));
+      return decayed_t::error_t::handle(std::forward<ErrorFunc>(func))
+                                       (std::forward<ErrorT>(e));
     }
   };
 
@@ -978,10 +976,9 @@ public:
       using decayed_t = std::decay_t<ErrorT>;
       static_assert(contains_once_v<decayed_t>,
                     "discarding disallowed ErrorT");
-      auto&& handler = decayed_t::error_t::handle([this] (auto&& error_v) {
+      decayed_t::error_t::handle([this] (auto&& error_v) {
         ceph_abort_msgf("%s: %s", msg ? msg : "", error_v.message().c_str());
-      });
-      std::invoke(std::move(handler), std::forward<ErrorT>(raw_error));
+      })(std::forward<ErrorT>(raw_error));
       return no_touch_error_marker{};
     }
   };
@@ -1350,10 +1347,9 @@ namespace ct_error {
         pre_assert();
       }
       using decayed_t = std::decay_t<ErrorT>;
-      auto&& handler = decayed_t::error_t::handle([this] (auto&& error_v) {
+      decayed_t::error_t::handle([this] (auto&& error_v) {
         ceph_abort_msgf("%s: %s", msg ? msg : "", error_v.message().c_str());
-      });
-      std::invoke(std::move(handler), std::forward<ErrorT>(raw_error));
+      })(std::forward<ErrorT>(raw_error));
       return no_touch_error_marker{};
     }
   };
@@ -1364,9 +1360,8 @@ namespace ct_error {
       error_func = std::forward<ErrorFunc>(error_func)
     ] (auto&& e) mutable -> decltype(auto) {
       using decayed_t = std::decay_t<decltype(e)>;
-      auto&& handler =
-        decayed_t::error_t::handle(std::forward<ErrorFunc>(error_func));
-      return std::invoke(std::move(handler), std::forward<decltype(e)>(e));
+      return decayed_t::error_t::handle(std::forward<ErrorFunc>(error_func))
+                                       (std::forward<decltype(e)>(e));
     };
   };
 }