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
11
third_party/nix/src/libstore/store-api.cc
vendored
11
third_party/nix/src/libstore/store-api.cc
vendored
|
|
@ -3,6 +3,7 @@
|
|||
#include <future>
|
||||
#include <utility>
|
||||
|
||||
#include <absl/status/status.h>
|
||||
#include <absl/strings/match.h>
|
||||
#include <absl/strings/numbers.h>
|
||||
#include <absl/strings/str_cat.h>
|
||||
|
|
@ -700,16 +701,20 @@ const Store::Stats& Store::getStats() {
|
|||
return stats;
|
||||
}
|
||||
|
||||
void Store::buildPaths(const PathSet& paths, BuildMode buildMode) {
|
||||
absl::Status Store::buildPaths(const PathSet& paths, BuildMode) {
|
||||
for (auto& path : paths) {
|
||||
if (isDerivation(path)) {
|
||||
unsupported("buildPaths");
|
||||
return absl::Status(absl::StatusCode::kUnimplemented,
|
||||
"buildPaths is unsupported");
|
||||
}
|
||||
}
|
||||
|
||||
if (queryValidPaths(paths).size() != paths.size()) {
|
||||
unsupported("buildPaths");
|
||||
return absl::Status(absl::StatusCode::kUnimplemented,
|
||||
"buildPaths is unsupported");
|
||||
}
|
||||
|
||||
return absl::OkStatus();
|
||||
}
|
||||
|
||||
void copyStorePath(ref<Store> srcStore, const ref<Store>& dstStore,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue