]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/common/errorator: fix errorator::pass_further and discard_all
authorSamuel Just <sjust@redhat.com>
Fri, 17 Jan 2020 20:33:42 +0000 (12:33 -0800)
committerSamuel Just <sjust@redhat.com>
Sat, 15 Feb 2020 01:28:38 +0000 (17:28 -0800)
Previously, both of these were invocable on all errors, but would
static_assert on invalid ones.  What we actually want is for them
to only be invocable on valid errors.  That way, we can do, for
instance:

  }).handle_error(
    roll_journal_segment_ertr::pass_further{},
    SegmentManager::open_ertr::all_same_way([this](auto &&e) {
      logger().error(
"error {} in close segment {}",
e,
current_journal_segment_id);
      ceph_assert(0 == "error in close");
      return;
    })

to explicitely propogate any errors in roll_journal_segment_ertr
while asserting on anything else.

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

index 0d2f3ccde50b7ce02336a0b014dbf1bd78a077d3..d9ae99913df4fff3f743c5d80a8602183059d02a 100644 (file)
@@ -630,6 +630,11 @@ private:
     friend inline auto ::seastar::do_with(T1&& rv1, T2&& rv2, T3_or_F&& rv3, More&&... more);
   };
 
+  class Enabler {};
+
+  template <typename T>
+  using EnableIf = typename std::enable_if<contains_once_v<std::decay_t<T>>, Enabler>::type;
+
 public:
   // HACK: `errorated_future_marker` and `_future` is just a hack to
   // specialize `seastar::futurize` for category of class templates:
@@ -644,7 +649,7 @@ public:
 
   // the visitor that forwards handling of all errors to next continuation
   struct pass_further {
-    template <class ErrorT>
+    template <class ErrorT, EnableIf<ErrorT>...>
     decltype(auto) operator()(ErrorT&& e) {
       static_assert(contains_once_v<std::decay_t<ErrorT>>,
                     "passing further disallowed ErrorT");
@@ -653,7 +658,7 @@ public:
   };
 
   struct discard_all {
-    template <class ErrorT>
+    template <class ErrorT, EnableIf<ErrorT>...>
     decltype(auto) operator()(ErrorT&&) {
       static_assert(contains_once_v<std::decay_t<ErrorT>>,
                     "discarding disallowed ErrorT");