aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr
diff options
context:
space:
mode:
authorBen Burdette <bburdette@gmail.com>2020-06-19 13:44:08 -0600
committerBen Burdette <bburdette@gmail.com>2020-06-19 13:44:08 -0600
commit54e8f550c9d5cc88c1161035d366871bb82d4a0c (patch)
treedbd84d78a0a0d7e2b107561487b6d7e033174687 /src/libexpr
parent4d1a4f02178b1f77a4bcf2de0483500d89c1424c (diff)
addErrorTrace
Diffstat (limited to 'src/libexpr')
-rw-r--r--src/libexpr/eval.cc24
-rw-r--r--src/libexpr/primops.cc10
2 files changed, 19 insertions, 15 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index b90a64357..c249add86 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -592,19 +592,19 @@ LocalNoInlineNoReturn(void throwUndefinedVarError(const Pos & pos, const char *
});
}
-LocalNoInline(void addErrorPrefix(Error & e, const char * s, const string & s2))
+LocalNoInline(void addErrorTrace(Error & e, const char * s, const string & s2))
{
- e.addPrefix(format(s) % s2);
+ e.addTrace(std::nullopt, hintfmt(s) % s2);
}
-LocalNoInline(void addErrorPrefix(Error & e, const char * s, const ExprLambda & fun, const Pos & pos))
+LocalNoInline(void addErrorTrace(Error & e, const Pos & pos, const char * s, const ExprLambda & fun))
{
- e.addPrefix(format(s) % fun.showNamePos() % pos);
+ e.addTrace(pos, hintfmt(s) % fun.showNamePos());
}
-LocalNoInline(void addErrorPrefix(Error & e, const char * s, const string & s2, const Pos & pos))
+LocalNoInline(void addErrorTrace(Error & e, const Pos & pos, const char * s, const string & s2))
{
- e.addPrefix(format(s) % s2 % pos);
+ e.addTrace(pos, hintfmt(s) % s2);
}
@@ -818,7 +818,7 @@ void EvalState::evalFile(const Path & path_, Value & v)
try {
eval(e, v);
} catch (Error & e) {
- addErrorPrefix(e, "while evaluating the file '%1%':\n", path2);
+ addErrorTrace(e, "while evaluating the file '%1%':", path2);
throw;
}
@@ -1068,8 +1068,8 @@ void ExprSelect::eval(EvalState & state, Env & env, Value & v)
} catch (Error & e) {
if (pos2 && pos2->file != state.sDerivationNix)
- addErrorPrefix(e, "while evaluating the attribute '%1%' at %2%:\n",
- showAttrPath(state, env, attrPath), *pos2);
+ addErrorTrace(e, *pos2, "while evaluating the attribute '%1%'",
+ showAttrPath(state, env, attrPath));
throw;
}
@@ -1241,7 +1241,9 @@ void EvalState::callFunction(Value & fun, Value & arg, Value & v, const Pos & po
try {
lambda.body->eval(*this, env2, v);
} catch (Error & e) {
- addErrorPrefix(e, "while evaluating %1%, called from %2%:\n", lambda, pos);
+ // TODO something different for 'called from' than usual addTrace?
+ // addErrorTrace(e, pos, "while evaluating %1%, called from %2%:", lambda);
+ addErrorTrace(e, pos, "while evaluating %1%:", lambda);
throw;
}
else
@@ -1516,7 +1518,7 @@ void EvalState::forceValueDeep(Value & v)
try {
recurse(*i.value);
} catch (Error & e) {
- addErrorPrefix(e, "while evaluating the attribute '%1%' at %2%:\n", i.name, *i.pos);
+ addErrorTrace(e, *i.pos, "while evaluating the attribute '%1%'", i.name);
throw;
}
}
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index 7b80d76b9..791fef27d 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -471,7 +471,8 @@ static void prim_addErrorContext(EvalState & state, const Pos & pos, Value * * a
v = *args[1];
} catch (Error & e) {
PathSet context;
- e.addPrefix(format("%1%\n") % state.coerceToString(pos, *args[0], context));
+ // TODO: is this right, include this pos?? Test it. esp with LOC.
+ e.addTrace(pos, hintfmt("%1%") % state.coerceToString(pos, *args[0], context));
throw;
}
}
@@ -563,7 +564,7 @@ static void prim_derivationStrict(EvalState & state, const Pos & pos, Value * *
try {
drvName = state.forceStringNoCtx(*attr->value, pos);
} catch (Error & e) {
- e.addPrefix(fmt("while evaluating the derivation attribute 'name' at %1%:\n", posDrvName));
+ e.addTrace(posDrvName, hintfmt("while evaluating the derivation attribute 'name'"));
throw;
}
@@ -696,8 +697,9 @@ static void prim_derivationStrict(EvalState & state, const Pos & pos, Value * *
}
} catch (Error & e) {
- e.addPrefix(format("while evaluating the attribute '%1%' of the derivation '%2%' at %3%:\n")
- % key % drvName % posDrvName);
+ e.addTrace(posDrvName,
+ hintfmt("while evaluating the attribute '%1%' of the derivation '%2%'",
+ key, drvName));
throw;
}
}