refactor(tvix): Make Store::buildPaths return a Status
Make Store::buildPaths return a Status with [[nodiscard]] rather than throwing exceptions to signal failure. This is the beginning of a long road to refactor the entire store API to be status/statusor based instead of using exceptions. Change-Id: I2e32371c95a25b87ad129987c217d49c6d6e0c85 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1745 Tested-by: BuildkiteCI Reviewed-by: kanepyork <rikingcoding@gmail.com>
This commit is contained in:
parent
aef3607bd3
commit
d1c38d9597
18 changed files with 137 additions and 32 deletions
9
third_party/nix/src/libstore/remote-store.cc
vendored
9
third_party/nix/src/libstore/remote-store.cc
vendored
|
|
@ -3,6 +3,7 @@
|
|||
#include <cerrno>
|
||||
#include <cstring>
|
||||
|
||||
#include <absl/status/status.h>
|
||||
#include <absl/strings/ascii.h>
|
||||
#include <fcntl.h>
|
||||
#include <glog/logging.h>
|
||||
|
|
@ -459,7 +460,8 @@ Path RemoteStore::addTextToStore(const std::string& name, const std::string& s,
|
|||
return readStorePath(*this, conn->from);
|
||||
}
|
||||
|
||||
void RemoteStore::buildPaths(const PathSet& drvPaths, BuildMode buildMode) {
|
||||
absl::Status RemoteStore::buildPaths(const PathSet& drvPaths,
|
||||
BuildMode buildMode) {
|
||||
auto conn(getConnection());
|
||||
conn->to << wopBuildPaths;
|
||||
if (GET_PROTOCOL_MINOR(conn->daemonVersion) >= 13) {
|
||||
|
|
@ -470,7 +472,8 @@ void RemoteStore::buildPaths(const PathSet& drvPaths, BuildMode buildMode) {
|
|||
/* Old daemons did not take a 'buildMode' parameter, so we
|
||||
need to validate it here on the client side. */
|
||||
if (buildMode != bmNormal) {
|
||||
throw Error(
|
||||
return absl::Status(
|
||||
absl::StatusCode::kInvalidArgument,
|
||||
"repairing or checking is not supported when building through the "
|
||||
"Nix daemon");
|
||||
}
|
||||
|
|
@ -485,6 +488,8 @@ void RemoteStore::buildPaths(const PathSet& drvPaths, BuildMode buildMode) {
|
|||
}
|
||||
conn.processStderr();
|
||||
readInt(conn->from);
|
||||
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
BuildResult RemoteStore::buildDerivation(const Path& drvPath,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue