From: Radoslaw Zarzynski Date: Fri, 19 Mar 2021 08:31:33 +0000 (+0000) Subject: crimson/common: stateful_error_t allows for void-taking handlers. X-Git-Tag: v17.1.0~2395^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=15bea958832a7dcfa6ac5a7f0fe1bfcf1a86b16a;p=ceph.git crimson/common: stateful_error_t allows for void-taking handlers. Before this commit there was an inconsistencty between `unthrowable_wrapper::handle()` and `stateful_error_t::handle()` in the regard of parameters the provided handler had to accept. The former was fine with void-taking handlers while the latter was not. Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/crimson/common/errorator.h b/src/crimson/common/errorator.h index 7fd053740841..058f9fe8c64b 100644 --- a/src/crimson/common/errorator.h +++ b/src/crimson/common/errorator.h @@ -190,14 +190,17 @@ struct stateful_error_t : error_t> { template static auto handle(Func&& func) { - static_assert(std::is_invocable_v); return [ func = std::forward(func) ] (stateful_error_t&& e) mutable -> decltype(auto) { try { std::rethrow_exception(e.ep); } catch (const ErrorT& obj) { - return std::invoke(std::forward(func), obj); + if constexpr (std::is_invocable_v) { + return std::invoke(std::forward(func), obj); + } else { + return std::invoke(std::forward(func)); + } } ceph_abort_msg("exception type mismatch – impossible!"); };