Skip to content

Commit bcda144

Browse files
committed
crimson/ertr: let ErrVisitorT return plain value if ValueFuncT returns seastar::future
The following corner case was unsupported till now: ```cpp return os->omap_get_values( ch, hoid, keys ).safe_then([] (FuturizedStore::omap_values_t&& vals) { return 0; }, FuturizedStore::read_errorator::all_same_way([] (auto&) { return -1; })).get(); ``` Signed-off-by: Radoslaw Zarzynski <[email protected]>
1 parent 25c18c5 commit bcda144

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/crimson/common/errorator.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,13 @@ class maybe_handle_error_t {
335335
// to throwing an exception by the handler.
336336
std::invoke(std::forward<ErrorVisitorT>(errfunc),
337337
ErrorT::error_t::from_exception_ptr(std::move(ep)));
338+
} else if constexpr (seastar::Future<decltype(result)>) {
339+
// result is seastar::future but return_t is e.g. int. If so,
340+
// the else clause cannot be used as seastar::future lacks
341+
// errorator_type member.
342+
result = seastar::make_ready_future<return_t>(
343+
std::invoke(std::forward<ErrorVisitorT>(errfunc),
344+
ErrorT::error_t::from_exception_ptr(std::move(ep))));
338345
} else {
339346
result = FuturatorT::type::errorator_type::template make_ready_future<return_t>(
340347
std::invoke(std::forward<ErrorVisitorT>(errfunc),

0 commit comments

Comments
 (0)