diff options
author | Griffin Smith <grfn@gws.fyi> | 2020-09-14T22·04-0400 |
---|---|---|
committer | glittershark <grfn@gws.fyi> | 2020-09-16T20·17+0000 |
commit | 96dbf4d68680b7bdf9fc51e061b87d8872870c8c (patch) | |
tree | 1597e9eab62694c6ba3b8a41deae0e1bad1d532f /third_party/nix/src | |
parent | fedbe693b9c0f5ba57fae82e3191efe8a633aa09 (diff) |
fix(tvix): Convert INVALID_ARGUMENT to InvalidPath r/1795
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>
Diffstat (limited to 'third_party/nix/src')
-rw-r--r-- | third_party/nix/src/libstore/rpc-store.cc | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/third_party/nix/src/libstore/rpc-store.cc b/third_party/nix/src/libstore/rpc-store.cc index 02975341fd40..993d111e8616 100644 --- a/third_party/nix/src/libstore/rpc-store.cc +++ b/third_party/nix/src/libstore/rpc-store.cc @@ -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; |