forked from lix-project/lix
trace when the foo
part of foo.bar.baz
errors
Turns errors like:
let
errpkg = throw "invalid foobar";
in errpkg.meta
error:
… while calling the 'throw' builtin
at «string»:2:12:
1| let
2| errpkg = throw "invalid foobar";
| ^
3| in errpkg.meta
error: invalid foobar
into errors like:
let
errpkg = throw "invalid foobar";
in errpkg.meta
error:
… while evaluating 'errpkg' to select 'meta' on it
at «string»:3:4:
2| errpkg = throw "invalid foobar";
3| in errpkg.meta
| ^
… while calling the 'throw' builtin
at «string»:2:12:
1| let
2| errpkg = throw "invalid foobar";
| ^
3| in errpkg.meta
error: invalid foobar
For the low price of one try/catch, you too can have the incorrect line
of code actually show up in the trace!
Change-Id: If8d6200ec1567706669d405c34adcd7e2d2cd29d
This commit is contained in:
parent
af94db77cf
commit
013b7ae114
|
@ -1433,7 +1433,22 @@ void ExprSelect::eval(EvalState & state, Env & env, Value & v)
|
|||
Value * vCurrent = &vFirst;
|
||||
// Position for the current attrset Value in this select chain.
|
||||
PosIdx posCurrent;
|
||||
e->eval(state, env, vFirst);
|
||||
|
||||
try {
|
||||
e->eval(state, env, vFirst);
|
||||
} catch (Error & e) {
|
||||
assert(this->e != nullptr);
|
||||
std::stringstream selectedOn;
|
||||
this->e->show(state.symbols, selectedOn);
|
||||
state.addErrorTrace(
|
||||
e,
|
||||
getPos(),
|
||||
"while evaluating '%s' to select '%s' on it",
|
||||
"a",
|
||||
"foo"
|
||||
);
|
||||
throw;
|
||||
}
|
||||
|
||||
try {
|
||||
auto dts = state.debugRepl
|
||||
|
|
|
@ -1,4 +1,10 @@
|
|||
error:
|
||||
… while evaluating 'a' to select 'foo' on it
|
||||
at /pwd/lang/eval-fail-recursion.nix:1:21:
|
||||
1| let a = {} // a; in a.foo
|
||||
| ^
|
||||
2|
|
||||
|
||||
… in the right operand of the update (//) operator
|
||||
at /pwd/lang/eval-fail-recursion.nix:1:12:
|
||||
1| let a = {} // a; in a.foo
|
||||
|
|
Loading…
Reference in a new issue