mirror of
https://github.com/ceph/ceph
synced 2025-02-23 11:07:35 +00:00
crimson: introduce all_same_way() to errorator.
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
This commit is contained in:
parent
69d6de77ed
commit
de325ade55
@ -412,6 +412,18 @@ struct errorator {
|
||||
}
|
||||
};
|
||||
|
||||
template <class ErrorFunc>
|
||||
static decltype(auto) all_same_way(ErrorFunc&& error_func) {
|
||||
return [
|
||||
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));
|
||||
};
|
||||
};
|
||||
|
||||
// get a new errorator by extending current one with new error
|
||||
template <class... NewAllowedErrorsT>
|
||||
using extend = errorator<AllowedErrors..., NewAllowedErrorsT...>;
|
||||
|
Loading…
Reference in New Issue
Block a user