improve nf7::AggregatePromise not to ignore errors from children

This commit is contained in:
falsycat 2022-10-29 01:13:51 +09:00
parent 8ef4abd75e
commit 31bbf118e1

View File

@ -28,7 +28,14 @@ class AggregatePromise final :
AggregatePromise& Add(auto fu) noexcept {
data_->Ref();
fu.Then([data = data_](auto&) { data->Unref(); });
fu.Then([data = data_](auto& fu) {
try {
fu.value();
data->Unref();
} catch (nf7::Exception&) {
data->Abort(std::current_exception());
}
});
return *this;
}
@ -52,6 +59,9 @@ class AggregatePromise final :
pro_.Return({});
}
}
void Abort(std::exception_ptr e) noexcept {
pro_.Throw(e);
}
nf7::Future<std::monostate> future() const noexcept {
return pro_.future();