From 70bcb39d3fe272164c122979ee36cf2f2ea8f084 Mon Sep 17 00:00:00 2001 From: Ben Burdette Date: Tue, 30 Jun 2020 15:44:19 -0600 Subject: [PATCH] double addtrace for 'called from' --- src/libexpr/eval.cc | 13 +++++-------- src/libutil/error.cc | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index 1cbbb7ade..e89948b94 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -597,11 +597,6 @@ LocalNoInline(void addErrorTrace(Error & e, const char * s, const string & s2)) e.addTrace(std::nullopt, s, s2); } -LocalNoInline(void addErrorTrace(Error & e, const Pos & pos, const char * s, const ExprLambda & fun)) -{ - e.addTrace(pos, s, fun.showNamePos()); -} - LocalNoInline(void addErrorTrace(Error & e, const Pos & pos, const char * s, const string & s2)) { e.addTrace(pos, s, s2); @@ -1241,9 +1236,11 @@ void EvalState::callFunction(Value & fun, Value & arg, Value & v, const Pos & po try { lambda.body->eval(*this, env2, v); } catch (Error & e) { - // 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); + addErrorTrace(e, lambda.pos, "while evaluating %s", + (lambda.name.set() + ? "'" + (string) lambda.name + "'" + : "anonymous lambdaction")); + addErrorTrace(e, pos, "from call site%s", ""); throw; } else diff --git a/src/libutil/error.cc b/src/libutil/error.cc index 02eb3f7cb..229c1e6ed 100644 --- a/src/libutil/error.cc +++ b/src/libutil/error.cc @@ -330,7 +330,7 @@ std::ostream& showErrorInfo(std::ostream &out, const ErrorInfo &einfo, bool show // traces if (showTrace && !einfo.traces.empty()) { - const string tracetitle(" show-trace output "); + const string tracetitle(" show-trace "); int fill = errwidth - tracetitle.length(); int lw = 0;