diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/libexpr/primops.cc | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index e7b79604699b..1ddeac6b2f88 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -756,8 +756,12 @@ static void prim_readFile(EvalState & state, const Pos & pos, Value * * args, Va { PathSet context; Path path = state.coerceToPath(pos, *args[0], context); - if (!context.empty()) - throw EvalError(format("string ‘%1%’ cannot refer to other paths, at %2%") % path % pos); + try { + realiseContext(context); + } catch (InvalidPathError & e) { + throw EvalError(format("cannot read ‘%1%’, since path ‘%2%’ is not valid, at %3%") + % path % e.path % pos); + } mkString(v, readFile(path).c_str()); } |