onerror to thenerror phase 2

Summary:
Replace Future::onError with Future::thenError:
 * to remove ambiguous typing
 * to ensure that the executor is not lost and the returned Future is still bound to an executor

See:
https://fb.workplace.com/groups/fbcode/permalink/2002251863144976/
for details.

Reviewed By: yfeldblum

Differential Revision: D13908257

fbshipit-source-id: 8b5315b019290f1c60087ca5716c31ebbf1f1be5
This commit is contained in:
Lee Howes 2019-02-01 13:07:58 -08:00 committed by Facebook Github Bot
parent 25327947e0
commit 4076449871
5 changed files with 32 additions and 24 deletions

View File

@ -131,18 +131,20 @@ Future<Unit> CheckoutAction::run(
std::shared_ptr<const Tree> oldTree) {
rc->setOldTree(std::move(oldTree));
})
.onError([rc = LoadingRefcount(this)](const exception_wrapper& ew) {
rc->error("error getting old tree", ew);
});
.thenError(
[rc = LoadingRefcount(this)](const exception_wrapper& ew) {
rc->error("error getting old tree", ew);
});
} else {
store->getBlob(oldScmEntry_.value().getHash())
.thenValue([rc = LoadingRefcount(this)](
std::shared_ptr<const Blob> oldBlob) {
rc->setOldBlob(std::move(oldBlob));
})
.onError([rc = LoadingRefcount(this)](const exception_wrapper& ew) {
rc->error("error getting old blob", ew);
});
.thenError(
[rc = LoadingRefcount(this)](const exception_wrapper& ew) {
rc->error("error getting old blob", ew);
});
}
}
@ -155,18 +157,20 @@ Future<Unit> CheckoutAction::run(
std::shared_ptr<const Tree> newTree) {
rc->setNewTree(std::move(newTree));
})
.onError([rc = LoadingRefcount(this)](const exception_wrapper& ew) {
rc->error("error getting new tree", ew);
});
.thenError(
[rc = LoadingRefcount(this)](const exception_wrapper& ew) {
rc->error("error getting new tree", ew);
});
} else {
store->getBlob(newEntry.getHash())
.thenValue([rc = LoadingRefcount(this)](
std::shared_ptr<const Blob> newBlob) {
rc->setNewBlob(std::move(newBlob));
})
.onError([rc = LoadingRefcount(this)](const exception_wrapper& ew) {
rc->error("error getting new blob", ew);
});
.thenError(
[rc = LoadingRefcount(this)](const exception_wrapper& ew) {
rc->error("error getting new blob", ew);
});
}
}
@ -177,7 +181,7 @@ Future<Unit> CheckoutAction::run(
.thenValue([rc = LoadingRefcount(this)](InodePtr inode) {
rc->setInode(std::move(inode));
})
.onError([rc = LoadingRefcount(this)](const exception_wrapper& ew) {
.thenError([rc = LoadingRefcount(this)](const exception_wrapper& ew) {
rc->error("error getting inode", ew);
});
}

View File

@ -281,9 +281,11 @@ folly::Future<folly::Unit> EdenMount::setupDotEden(TreeInodePtr root) {
// its inode here
return dotEdenInode->getOrLoadChild(kDotEdenSymlinkName)
.unit()
.onError([=](const InodeError& /*err*/) {
createDotEdenSymlink(dotEdenInode);
})
.thenError(
folly::tag_t<InodeError>{},
[=](const InodeError& /*err*/) {
createDotEdenSymlink(dotEdenInode);
})
.ensure([=] {
// Assign this number after we've fixed up the directory
// contents, otherwise we'll lock ourselves out of

View File

@ -451,8 +451,8 @@ void TreeInode::registerInodeLoadComplete(
unique_ptr<InodeBase>&& childInode) {
self->inodeLoadComplete(childName, std::move(childInode));
})
.onError([self = inodePtrFromThis(),
number](const folly::exception_wrapper& ew) {
.thenError([self = inodePtrFromThis(),
number](const folly::exception_wrapper& ew) {
self->getInodeMap()->inodeLoadFailed(number, ew);
});
}

View File

@ -226,7 +226,7 @@ Future<Unit> EdenServer::unmountAll() {
info.unmountPromise.getFuture()](auto&&) mutable {
return std::move(unmountFuture);
})
.onError(
.thenError(
[path = entry.first.str()](folly::exception_wrapper&& ew) {
XLOG(ERR) << "Failed to perform unmount for \"" << path
<< "\": " << folly::exceptionStr(ew);
@ -878,7 +878,7 @@ Future<Unit> EdenServer::unmount(StringPiece mountPath) {
return std::move(f);
});
})
.onError([path = mountPath.str()](folly::exception_wrapper&& ew) {
.thenError([path = mountPath.str()](folly::exception_wrapper&& ew) {
XLOG(ERR) << "Failed to perform unmount for \"" << path
<< "\": " << folly::exceptionStr(ew);
return makeFuture<Unit>(std::move(ew));

View File

@ -511,8 +511,8 @@ Future<unique_ptr<Tree>> HgBackingStore::importTreeImpl(
KeySpace::TreeFamily, edenTreeID, serialized.second.coalesce());
return makeFuture(std::move(tree));
})
.onError([this, manifestNode, edenTreeID, ownedPath, writeBatch](
const folly::exception_wrapper& ex) mutable {
.thenError([this, manifestNode, edenTreeID, ownedPath, writeBatch](
const folly::exception_wrapper& ex) mutable {
XLOG(WARN) << "got exception from MononokeBackingStore: "
<< ex.what();
return fetchTreeFromHgCacheOrImporter(
@ -761,8 +761,10 @@ Future<unique_ptr<Blob>> HgBackingStore::getBlob(const Hash& id) {
<< hgInfo.revHash().toString() << " from mononoke";
auto revHashCopy = hgInfo.revHash();
return mononoke_->getBlob(revHashCopy)
.onError([this, id, path = hgInfo.path().copy(), revHash = revHashCopy](
const folly::exception_wrapper& ex) {
.thenError([this,
id,
path = hgInfo.path().copy(),
revHash = revHashCopy](const folly::exception_wrapper& ex) {
XLOG(ERR) << "Error while fetching file contents of '" << path
<< "', " << revHash.toString()
<< " from mononoke: " << ex.what()