diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index 050b49833..0febff022 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -2168,19 +2168,11 @@ std::string_view EvalState::forceString(Value & v, PathSet & context, const PosI std::string_view EvalState::forceStringNoCtx(Value & v, const PosIdx pos, std::string_view errorCtx) { - try { - auto s = forceString(v, pos, errorCtx); - if (v.string.context) { - if (pos) - throwError(noPos, "the string '%1%' is not allowed to refer to a store path (such as '%2%')", v.string.s, v.string.context[0], 0, 0, 0, 0, noPos, "", 0, 0, 0); - else - throwError(noPos, "the string '%1%' is not allowed to refer to a store path (such as '%2%')", v.string.s, v.string.context[0], 0, 0, 0, 0, noPos, "", 0, 0, 0); - } - return s; - } catch (Error & e) { - e.addTrace(positions[pos], errorCtx); - throw; + auto s = forceString(v, pos, errorCtx); + if (v.string.context) { + throwErrorWithTrace(noPos, "the string '%1%' is not allowed to refer to a store path (such as '%2%')", v.string.s, v.string.context[0], 0, 0, 0, 0, noPos, "", 0, pos, errorCtx, 0, 0); } + return s; }