Add a trace to all errors in addPath()

This commit is contained in:
Eelco Dolstra 2021-10-07 13:47:15 +02:00
parent 4806f2f6b0
commit c4dcf3cf25

View file

@ -1847,7 +1847,7 @@ static void addPath(
EvalState & state,
const Pos & pos,
const string & name,
const Path & path_,
Path path,
Value * filterFun,
FileIngestionMethod method,
const std::optional<Hash> expectedHash,
@ -1855,22 +1855,13 @@ static void addPath(
const PathSet & context)
{
try {
// FIXME: handle CA derivation outputs (where path_ needs to
// FIXME: handle CA derivation outputs (where path needs to
// be rewritten to the actual output).
state.realiseContext(context);
} catch (InvalidPathError & e) {
throw EvalError({
.msg = hintfmt("cannot add path '%s', since path '%s' is not valid", path_, e.path),
.errPos = pos
});
} catch (Error & e) {
e.addTrace(pos, "while adding path '%s'", path_);
throw;
}
const auto path = evalSettings.pureEval && expectedHash
? path_
: state.checkSourcePath(path_);
path = evalSettings.pureEval && expectedHash
? path
: state.checkSourcePath(path);
if (state.store->isInStore(path)) {
auto storePath = state.store->toStorePath(path).first;
@ -1921,6 +1912,11 @@ static void addPath(
mkString(v, dstPath, {dstPath});
state.allowPath(v.string.s);
} catch (Error & e) {
e.addTrace(pos, "while adding path '%s'", path);
throw;
}
}