diff options
author | Griffin Smith <grfn@gws.fyi> | 2020-08-14T02·06-0400 |
---|---|---|
committer | glittershark <grfn@gws.fyi> | 2020-08-14T03·06+0000 |
commit | d1c38d9597e110bef92a548c86a651174bd385dc (patch) | |
tree | 98d64ac81a4f7ca91ad21f732c84bdc3f73df9cb /third_party/nix/src/nix-store | |
parent | aef3607bd332a9a6adbb150abe63250745972532 (diff) |
refactor(tvix): Make Store::buildPaths return a Status r/1649
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>
Diffstat (limited to 'third_party/nix/src/nix-store')
-rw-r--r-- | third_party/nix/src/nix-store/nix-store.cc | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/third_party/nix/src/nix-store/nix-store.cc b/third_party/nix/src/nix-store/nix-store.cc index 152d716641b6..a036fcec8bd8 100644 --- a/third_party/nix/src/nix-store/nix-store.cc +++ b/third_party/nix/src/nix-store/nix-store.cc @@ -16,6 +16,7 @@ #include "libstore/worker-protocol.hh" #include "libutil/archive.hh" #include "libutil/monitor-fd.hh" +#include "libutil/status.hh" #include "libutil/util.hh" #include "nix-store/dotgraph.hh" #include "nix-store/graphml.hh" @@ -68,7 +69,7 @@ static PathSet realisePath(Path path, bool build = true) { if (isDerivation(p.first)) { if (build) { - store->buildPaths({path}); + util::OkOrThrow(store->buildPaths({path})); } Derivation drv = store->derivationFromPath(p.first); rootNr++; @@ -184,7 +185,8 @@ static void opRealise(Strings opFlags, Strings opArgs) { } /* Build all paths at the same time to exploit parallelism. */ - store->buildPaths(PathSet(paths.begin(), paths.end()), buildMode); + util::OkOrThrow( + store->buildPaths(PathSet(paths.begin(), paths.end()), buildMode)); if (!ignoreUnknown) { for (auto& i : paths) { @@ -1002,7 +1004,7 @@ static void opServe(Strings opFlags, Strings opArgs) { does one path at a time. */ if (!willSubstitute.empty()) { try { - store->buildPaths(willSubstitute); + util::OkOrThrow(store->buildPaths(willSubstitute)); } catch (Error& e) { LOG(WARNING) << e.msg(); } @@ -1064,7 +1066,7 @@ static void opServe(Strings opFlags, Strings opArgs) { try { MonitorFdHup monitor(in.fd); - store->buildPaths(paths); + util::OkOrThrow(store->buildPaths(paths)); out << 0; } catch (Error& e) { assert(e.status); |