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/libstore/build.cc | |
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/libstore/build.cc')
-rw-r--r-- | third_party/nix/src/libstore/build.cc | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/third_party/nix/src/libstore/build.cc b/third_party/nix/src/libstore/build.cc index 6aad99b37a40..a9d40991d30d 100644 --- a/third_party/nix/src/libstore/build.cc +++ b/third_party/nix/src/libstore/build.cc @@ -13,6 +13,7 @@ #include <string> #include <thread> +#include <absl/status/status.h> #include <absl/strings/ascii.h> #include <absl/strings/numbers.h> #include <absl/strings/str_cat.h> @@ -4686,7 +4687,8 @@ static void primeCache(Store& store, const PathSet& paths) { } } -void LocalStore::buildPaths(const PathSet& drvPaths, BuildMode buildMode) { +absl::Status LocalStore::buildPaths(const PathSet& drvPaths, + BuildMode buildMode) { Worker worker(*this); primeCache(*this, drvPaths); @@ -4717,8 +4719,12 @@ void LocalStore::buildPaths(const PathSet& drvPaths, BuildMode buildMode) { } if (!failed.empty()) { - throw Error(worker.exitStatus(), "build of %s failed", showPaths(failed)); + return absl::Status( + absl::StatusCode::kInternal, + absl::StrFormat("build of %s failed (exit code %d)", showPaths(failed), + worker.exitStatus())); } + return absl::OkStatus(); } BuildResult LocalStore::buildDerivation(const Path& drvPath, |