mirror of
https://github.com/NixOS/nix.git
synced 2025-12-13 12:31:04 +01:00
Simplify handling of statuses for build errors
Instead of passing them around separately, or doing finicky logic in a try-catch block to recover them, just make `BuildError` always contain a status, and make it the thrower's responsibility to set it. This is much more simple and explicit. Once that change is done, split the `done` functions of `DerivationGoal` and `DerivationBuildingGoal` into separate success and failure functions, which ends up being easier to understand and hardly any duplication. Also, change the handling of failures in resolved cases to use `BuildResult::DependencyFailed` and a new message. This is because the underlying derivation will also get its message printed --- which is good, because in general the resolved derivation is not unique. One dyn drv test had to be updated, but CA (and dyn drv) is experimental, so I do not mind. Finally, delete `SubstError` because it is unused.
This commit is contained in:
parent
0590b13156
commit
169033001d
16 changed files with 153 additions and 92 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#include <queue>
|
||||
|
||||
#include "nix/store/store-api.hh"
|
||||
#include "nix/store/build-result.hh"
|
||||
|
||||
#include "derivation-check.hh"
|
||||
|
||||
|
|
@ -54,6 +55,7 @@ void checkOutputs(
|
|||
auto applyChecks = [&](const DerivationOptions::OutputChecks & checks) {
|
||||
if (checks.maxSize && info.narSize > *checks.maxSize)
|
||||
throw BuildError(
|
||||
BuildResult::OutputRejected,
|
||||
"path '%s' is too large at %d bytes; limit is %d bytes",
|
||||
store.printStorePath(info.path),
|
||||
info.narSize,
|
||||
|
|
@ -63,6 +65,7 @@ void checkOutputs(
|
|||
uint64_t closureSize = getClosure(info.path).second;
|
||||
if (closureSize > *checks.maxClosureSize)
|
||||
throw BuildError(
|
||||
BuildResult::OutputRejected,
|
||||
"closure of path '%s' is too large at %d bytes; limit is %d bytes",
|
||||
store.printStorePath(info.path),
|
||||
closureSize,
|
||||
|
|
@ -83,6 +86,7 @@ void checkOutputs(
|
|||
std::string outputsListing =
|
||||
concatMapStringsSep(", ", outputs, [](auto & o) { return o.first; });
|
||||
throw BuildError(
|
||||
BuildResult::OutputRejected,
|
||||
"derivation '%s' output check for '%s' contains an illegal reference specifier '%s',"
|
||||
" expected store path or output name (one of [%s])",
|
||||
store.printStorePath(drvPath),
|
||||
|
|
@ -115,6 +119,7 @@ void checkOutputs(
|
|||
badPathsStr += store.printStorePath(i);
|
||||
}
|
||||
throw BuildError(
|
||||
BuildResult::OutputRejected,
|
||||
"output '%s' is not allowed to refer to the following paths:%s",
|
||||
store.printStorePath(info.path),
|
||||
badPathsStr);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue