about summary refs log tree commit diff
path: root/third_party/nix
diff options
context:
space:
mode:
authorGriffin Smith <grfn@gws.fyi>2020-08-08T18·30-0400
committerglittershark <grfn@gws.fyi>2020-08-08T20·03+0000
commit053a1380023591e8eb3f514b4214226c95da207d (patch)
treeb5034486b23cef83d96ae0917af6e7d69a0529c1 /third_party/nix
parent311511385455f680aedf78aab761fcebf3ca7731 (diff)
fix(tvix): Wrap remaining RPCs in HandleExceptions r/1618
Wrap the BuildPaths and AddTextToStore RPC handlers in HandleExceptions.
These were missed in the original pass due to a merge.

Change-Id: Ie5be45e6098fba7a2b6b1c1be81578cb742c2880
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1689
Tested-by: BuildkiteCI
Reviewed-by: kanepyork <rikingcoding@gmail.com>
Diffstat (limited to 'third_party/nix')
-rw-r--r--third_party/nix/src/nix-daemon/nix-daemon-proto.cc50
1 files changed, 29 insertions, 21 deletions
diff --git a/third_party/nix/src/nix-daemon/nix-daemon-proto.cc b/third_party/nix/src/nix-daemon/nix-daemon-proto.cc
index 33e440dfde92..58dbec04f30a 100644
--- a/third_party/nix/src/nix-daemon/nix-daemon-proto.cc
+++ b/third_party/nix/src/nix-daemon/nix-daemon-proto.cc
@@ -256,35 +256,43 @@ class WorkerServiceImpl final : public WorkerService::Service {
   Status AddTextToStore(grpc::ServerContext*,
                         const nix::proto::AddTextToStoreRequest* request,
                         nix::proto::StorePath* response) override {
-    PathSet references;
-    for (const auto& ref : request->references()) {
-      references.insert(ref);
-    }
-    auto path =
-        store_->addTextToStore(request->name(), request->content(), references);
-    response->set_path(path);
-    return Status::OK;
+    return HandleExceptions(
+        [&]() -> Status {
+          PathSet references;
+          for (const auto& ref : request->references()) {
+            references.insert(ref);
+          }
+          auto path = store_->addTextToStore(request->name(),
+                                             request->content(), references);
+          response->set_path(path);
+          return Status::OK;
+        },
+        __FUNCTION__);
   }
 
   Status BuildPaths(grpc::ServerContext*,
                     const nix::proto::BuildPathsRequest* request,
                     google::protobuf::Empty*) override {
-    PathSet drvs;
-    for (const auto& drv : request->drvs()) {
-      drvs.insert(drv);
-    }
-    auto mode = BuildModeFrom(request->mode());
+    return HandleExceptions(
+        [&]() -> Status {
+          PathSet drvs;
+          for (const auto& drv : request->drvs()) {
+            drvs.insert(drv);
+          }
+          auto mode = BuildModeFrom(request->mode());
 
-    if (!mode.has_value()) {
-      return Status(grpc::StatusCode::INTERNAL, "Invalid build mode");
-    }
+          if (!mode.has_value()) {
+            return Status(grpc::StatusCode::INTERNAL, "Invalid build mode");
+          }
 
-    // TODO(grfn): If mode is repair and not trusted, we need to return an error
-    // here (but we can't yet because we don't know anything about trusted
-    // users)
-    store_->buildPaths(drvs, mode.value());
+          // TODO(grfn): If mode is repair and not trusted, we need to return an
+          // error here (but we can't yet because we don't know anything about
+          // trusted users)
+          store_->buildPaths(drvs, mode.value());
 
-    return Status::OK;
+          return Status::OK;
+        },
+        __FUNCTION__);
   }
 
   Status AddTempRoot(grpc::ServerContext*, const nix::proto::StorePath* request,