diff options
author | Guillaume Maudoux <guillaume.maudoux@tweag.io> | 2022-10-20 14:18:35 +0200 |
---|---|---|
committer | Guillaume Maudoux <guillaume.maudoux@tweag.io> | 2022-10-20 14:18:35 +0200 |
commit | 31ce52a045ac384b542f8409f20c0461ab6263ac (patch) | |
tree | bbd64ea955e8c4ffa4fe96933f45621f8e2347ed /src/libexpr | |
parent | 512f6be9b5dae74d3a6112f90090bec442d2a86a (diff) |
Fix context message being printed twice with forceStringNoCtx
Diffstat (limited to 'src/libexpr')
-rw-r--r-- | src/libexpr/eval.cc | 16 |
1 files changed, 4 insertions, 12 deletions
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<EvalError>(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<EvalError>(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<EvalError>(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; } |