-
Notifications
You must be signed in to change notification settings - Fork 74
Closed
Labels
Description
The following code works, and prints both "Recover on test called" and "Recover on package called"
// Make a ready resolved future
auto test = stlab::make_ready_future(stlab::immediate_executor);
// Create a future that we'll resolve later.
auto package = stlab::package<void()>(stlab::immediate_executor, []() {});
// Chain this to-be-resolved future after test.
test.then([package]() { return package.second; })
// Chain something to catch resolves/rejections
.recover([](stlab::future<void> f) {
std::cout << "Recover on test called" << std::endl;
})
.detach();
// Also stay informed of the package:
package.second.recover([](stlab::future<void> f) {
std::cout << "Recover on package called" << std::endl;
}).detach();
// Now resolve the chained future.
package.first();However, if we have the inner package fail, it will only print "Recover on package called":
// Make a ready resolved future
auto test = stlab::make_ready_future(stlab::immediate_executor);
// Create a future that we'll resolve later.
auto package = stlab::package<void()>(stlab::immediate_executor, []() {throw std::runtime_error("Oops");});
// Chain this to-be-resolved future after test.
test.then([package]() { return package.second; })
// Chain something to catch resolves/rejections
.recover([](stlab::future<void> f) {
std::cout << "Recover on test called" << std::endl;
})
.detach();
// Also stay informed of the package:
package.second.recover([](stlab::future<void> f) {
std::cout << "Recover on package called" << std::endl;
}).detach();
// Now resolve the chained future.
package.first();I'm running a clone from the master branch that is up to date as of today...
Reactions are currently unavailable