From: Samuel Just Date: Fri, 17 Jan 2020 20:56:46 +0000 (-0800) Subject: common/crimson/errorator: add universal pass_further_all, discard_all, all_same_way X-Git-Tag: v15.1.1~387^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=01399ebfd296fb3d08284078070c0d798ee56c7e;p=ceph-ci.git common/crimson/errorator: add universal pass_further_all, discard_all, all_same_way In many cases, we simply want to add catch-all handling. Signed-off-by: Samuel Just --- diff --git a/src/crimson/common/errorator.h b/src/crimson/common/errorator.h index d9ae99913df..3750b67360a 100644 --- a/src/crimson/common/errorator.h +++ b/src/crimson/common/errorator.h @@ -872,6 +872,31 @@ namespace ct_error { ct_error_code; using not_connected = ct_error_code; using timed_out = ct_error_code; + + struct pass_further_all { + template + decltype(auto) operator()(ErrorT&& e) { + return std::forward(e); + } + }; + + struct discard_all { + template + decltype(auto) operator()(ErrorT&&) { + } + }; + + template + static decltype(auto) all_same_way(ErrorFunc&& error_func) { + return [ + error_func = std::forward(error_func) + ] (auto&& e) mutable -> decltype(auto) { + using decayed_t = std::decay_t; + auto&& handler = + decayed_t::error_t::handle(std::forward(error_func)); + return std::invoke(std::move(handler), std::forward(e)); + }; + }; } using stateful_errc = stateful_error_t;