fix(tvix): Convert INVALID_ARGUMENT to InvalidPath

The code that calls queryPathInfoUncached explicitly catches the
InvalidPath exception and translates it into a null result - but the RPC
code was throwing a regular old Error for invalid paths. At some point
we should get rid of all the exception-driven control flow in this whole
thing, but in the meantime this gets us back to functional.

Change-Id: I2a38790ee0c691ab0c8394c7738d7693fa42aa10
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1980
Tested-by: BuildkiteCI
Reviewed-by: kanepyork <rikingcoding@gmail.com>
This commit is contained in:
Griffin Smith 2020-09-14 18:04:14 -04:00 committed by glittershark
parent fedbe693b9
commit 96dbf4d686

View file

@ -19,6 +19,7 @@
#include <grpcpp/impl/codegen/client_context.h>
#include <grpcpp/impl/codegen/completion_queue.h>
#include <grpcpp/impl/codegen/status.h>
#include <grpcpp/impl/codegen/status_code_enum.h>
#include <grpcpp/impl/codegen/sync_stream.h>
#include <grpcpp/security/credentials.h>
#include <sys/ucontext.h>
@ -135,8 +136,11 @@ void RpcStore::queryPathInfoUncached(
try {
proto::PathInfo path_info;
SuccessOrThrow(stub_->QueryPathInfo(&ctx, store_path, &path_info),
__FUNCTION__);
auto result = stub_->QueryPathInfo(&ctx, store_path, &path_info);
if (result.error_code() == grpc::INVALID_ARGUMENT) {
throw InvalidPath(absl::StrFormat("path '%s' is not valid", path));
}
SuccessOrThrow(result);
std::shared_ptr<ValidPathInfo> info;