summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libexpr/attr-path.cc2
-rw-r--r--src/libexpr/attr-set.hh2
-rw-r--r--src/libexpr/eval-inline.hh4
-rw-r--r--src/libexpr/eval.cc45
-rw-r--r--src/libexpr/eval.hh2
-rw-r--r--src/libexpr/flake/flake.cc6
-rw-r--r--src/libexpr/nixexpr.cc19
-rw-r--r--src/libexpr/nixexpr.hh9
-rw-r--r--src/libexpr/parser.y45
-rw-r--r--src/libexpr/primops.cc103
-rw-r--r--src/libexpr/primops/context.cc6
-rw-r--r--src/libexpr/primops/fetchGit.cc4
-rw-r--r--src/libexpr/primops/fetchMercurial.cc4
-rw-r--r--src/libexpr/primops/fetchTree.cc6
-rw-r--r--src/libexpr/primops/fromTOML.cc2
-rw-r--r--src/libfetchers/cache.hh2
-rw-r--r--src/libmain/loggers.cc2
-rw-r--r--src/libmain/progress-bar.cc2
-rw-r--r--src/libmain/shared.cc4
-rw-r--r--src/libstore/build.cc11
-rw-r--r--src/libstore/builtins/fetchurl.cc9
-rw-r--r--src/libstore/daemon.cc13
-rw-r--r--src/libstore/globals.cc2
-rw-r--r--src/libstore/globals.hh4
-rw-r--r--src/libstore/local-store.cc11
-rw-r--r--src/libstore/local-store.hh2
-rw-r--r--src/libstore/path.hh1
-rw-r--r--src/libstore/remote-store.cc38
-rw-r--r--src/libstore/remote-store.hh1
-rw-r--r--src/libstore/store-api.cc10
-rw-r--r--src/libstore/store-api.hh7
-rw-r--r--src/libstore/worker-protocol.hh6
-rw-r--r--src/libutil/archive.cc2
-rw-r--r--src/libutil/error.cc251
-rw-r--r--src/libutil/error.hh86
-rw-r--r--src/libutil/hash.cc2
-rw-r--r--src/libutil/logging.cc10
-rw-r--r--src/libutil/logging.hh11
-rw-r--r--src/libutil/tests/logging.cc130
-rw-r--r--src/nix-env/nix-env.cc4
-rw-r--r--src/nix/develop.cc10
-rw-r--r--src/nix/flake.cc18
-rw-r--r--src/nix/repl.cc6
43 files changed, 636 insertions, 278 deletions
diff --git a/src/libexpr/attr-path.cc b/src/libexpr/attr-path.cc
index 2e2a17b14..83854df49 100644
--- a/src/libexpr/attr-path.cc
+++ b/src/libexpr/attr-path.cc
@@ -130,7 +130,7 @@ Pos findDerivationFilename(EvalState & state, Value & v, std::string what)
Symbol file = state.symbols.create(filename);
- return { file, lineno, 0 };
+ return { foFile, file, lineno, 0 };
}
diff --git a/src/libexpr/attr-set.hh b/src/libexpr/attr-set.hh
index c601d09c2..7eaa16c59 100644
--- a/src/libexpr/attr-set.hh
+++ b/src/libexpr/attr-set.hh
@@ -78,7 +78,7 @@ public:
if (!a)
throw Error({
.hint = hintfmt("attribute '%s' missing", name),
- .nixCode = NixCode { .errPos = pos }
+ .errPos = pos
});
return *a;
diff --git a/src/libexpr/eval-inline.hh b/src/libexpr/eval-inline.hh
index 3d544c903..30f6ec7db 100644
--- a/src/libexpr/eval-inline.hh
+++ b/src/libexpr/eval-inline.hh
@@ -11,7 +11,7 @@ LocalNoInlineNoReturn(void throwEvalError(const Pos & pos, const char * s))
{
throw EvalError({
.hint = hintfmt(s),
- .nixCode = NixCode { .errPos = pos }
+ .errPos = pos
});
}
@@ -25,7 +25,7 @@ LocalNoInlineNoReturn(void throwTypeError(const Pos & pos, const char * s, const
{
throw TypeError({
.hint = hintfmt(s, showType(v)),
- .nixCode = NixCode { .errPos = pos }
+ .errPos = pos
});
}
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index ba600ad0c..5510c64e9 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -544,7 +544,7 @@ LocalNoInlineNoReturn(void throwEvalError(const Pos & pos, const char * s, const
{
throw EvalError({
.hint = hintfmt(s, s2),
- .nixCode = NixCode { .errPos = pos }
+ .errPos = pos
});
}
@@ -557,7 +557,7 @@ LocalNoInlineNoReturn(void throwEvalError(const Pos & pos, const char * s, const
{
throw EvalError({
.hint = hintfmt(s, s2, s3),
- .nixCode = NixCode { .errPos = pos }
+ .errPos = pos
});
}
@@ -566,7 +566,7 @@ LocalNoInlineNoReturn(void throwEvalError(const Pos & p1, const char * s, const
// p1 is where the error occurred; p2 is a position mentioned in the message.
throw EvalError({
.hint = hintfmt(s, sym, p2),
- .nixCode = NixCode { .errPos = p1 }
+ .errPos = p1
});
}
@@ -574,7 +574,7 @@ LocalNoInlineNoReturn(void throwTypeError(const Pos & pos, const char * s))
{
throw TypeError({
.hint = hintfmt(s),
- .nixCode = NixCode { .errPos = pos }
+ .errPos = pos
});
}
@@ -587,7 +587,7 @@ LocalNoInlineNoReturn(void throwTypeError(const Pos & pos, const char * s, const
{
throw TypeError({
.hint = hintfmt(s, fun.showNamePos(), s2),
- .nixCode = NixCode { .errPos = pos }
+ .errPos = pos
});
}
@@ -595,7 +595,7 @@ LocalNoInlineNoReturn(void throwAssertionError(const Pos & pos, const char * s,
{
throw AssertionError({
.hint = hintfmt(s, s1),
- .nixCode = NixCode { .errPos = pos }
+ .errPos = pos
});
}
@@ -603,23 +603,18 @@ LocalNoInlineNoReturn(void throwUndefinedVarError(const Pos & pos, const char *
{
throw UndefinedVarError({
.hint = hintfmt(s, s1),
- .nixCode = NixCode { .errPos = pos }
+ .errPos = pos
});
}
-LocalNoInline(void addErrorPrefix(Error & e, const char * s, const string & s2))
+LocalNoInline(void addErrorTrace(Error & e, const char * s, const string & s2))
{
- e.addPrefix(format(s) % s2);
+ e.addTrace(std::nullopt, s, s2);
}
-LocalNoInline(void addErrorPrefix(Error & e, const char * s, const ExprLambda & fun, const Pos & pos))
+LocalNoInline(void addErrorTrace(Error & e, const Pos & pos, const char * s, const string & s2))
{
- e.addPrefix(format(s) % fun.showNamePos() % pos);
-}
-
-LocalNoInline(void addErrorPrefix(Error & e, const char * s, const string & s2, const Pos & pos))
-{
- e.addPrefix(format(s) % s2 % pos);
+ e.addTrace(pos, s, s2);
}
@@ -838,7 +833,7 @@ void EvalState::evalFile(const Path & path_, Value & v, bool mustBeTrivial)
throw Error("file '%s' must be an attribute set", path);
eval(e, v);
} catch (Error & e) {
- addErrorPrefix(e, "while evaluating the file '%1%':\n", path2);
+ addErrorTrace(e, "while evaluating the file '%1%':", path2);
throw;
}
@@ -1088,8 +1083,8 @@ void ExprSelect::eval(EvalState & state, Env & env, Value & v)
} catch (Error & e) {
if (pos2 && pos2->file != state.sDerivationNix)
- addErrorPrefix(e, "while evaluating the attribute '%1%' at %2%:\n",
- showAttrPath(state, env, attrPath), *pos2);
+ addErrorTrace(e, *pos2, "while evaluating the attribute '%1%'",
+ showAttrPath(state, env, attrPath));
throw;
}
@@ -1257,11 +1252,15 @@ void EvalState::callFunction(Value & fun, Value & arg, Value & v, const Pos & po
/* Evaluate the body. This is conditional on showTrace, because
catching exceptions makes this function not tail-recursive. */
- if (settings.showTrace)
+ if (loggerSettings.showTrace.get())
try {
lambda.body->eval(*this, env2, v);
} catch (Error & e) {
- addErrorPrefix(e, "while evaluating %1%, called from %2%:\n", lambda, pos);
+ addErrorTrace(e, lambda.pos, "while evaluating %s",
+ (lambda.name.set()
+ ? "'" + (string) lambda.name + "'"
+ : "anonymous lambdaction"));
+ addErrorTrace(e, pos, "from call site%s", "");
throw;
}
else
@@ -1536,7 +1535,7 @@ void EvalState::forceValueDeep(Value & v)
try {
recurse(*i.value);
} catch (Error & e) {
- addErrorPrefix(e, "while evaluating the attribute '%1%' at %2%:\n", i.name, *i.pos);
+ addErrorTrace(e, *i.pos, "while evaluating the attribute '%1%'", i.name);
throw;
}
}
@@ -1979,7 +1978,7 @@ string ExternalValueBase::coerceToString(const Pos & pos, PathSet & context, boo
{
throw TypeError({
.hint = hintfmt("cannot coerce %1% to a string", showType()),
- .nixCode = NixCode { .errPos = pos }
+ .errPos = pos
});
}
diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh
index 87bb42c11..8986952e3 100644
--- a/src/libexpr/eval.hh
+++ b/src/libexpr/eval.hh
@@ -253,7 +253,7 @@ private:
friend struct ExprAttrs;
friend struct ExprLet;
- Expr * parse(const char * text, const Path & path,
+ Expr * parse(const char * text, FileOrigin origin, const Path & path,
const Path & basePath, StaticEnv & staticEnv);
public:
diff --git a/src/libexpr/flake/flake.cc b/src/libexpr/flake/flake.cc
index 871af07b0..fd168b74f 100644
--- a/src/libexpr/flake/flake.cc
+++ b/src/libexpr/flake/flake.cc
@@ -123,7 +123,7 @@ static FlakeInput parseFlakeInput(EvalState & state,
attr.name, showType(*attr.value));
}
} catch (Error & e) {
- e.addPrefix(fmt("in flake attribute '%s' at '%s':\n", attr.name, *attr.pos));
+ e.addTrace(*attr.pos, hintfmt("in flake attribute '%s'", attr.name));
throw;
}
}
@@ -132,7 +132,7 @@ static FlakeInput parseFlakeInput(EvalState & state,
try {
input.ref = FlakeRef::fromAttrs(attrs);
} catch (Error & e) {
- e.addPrefix(fmt("in flake input at '%s':\n", pos));
+ e.addTrace(pos, hintfmt("in flake input"));
throw;
}
else {
@@ -195,7 +195,7 @@ static Flake getFlake(
Value vInfo;
state.evalFile(flakeFile, vInfo, true); // FIXME: symlink attack
- expectType(state, tAttrs, vInfo, Pos(state.symbols.create(flakeFile), 0, 0));
+ expectType(state, tAttrs, vInfo, Pos(foFile, state.symbols.create(flakeFile), 0, 0));
auto sEdition = state.symbols.create("edition"); // FIXME: remove soon
diff --git a/src/libexpr/nixexpr.cc b/src/libexpr/nixexpr.cc
index b4b65883d..d5698011f 100644
--- a/src/libexpr/nixexpr.cc
+++ b/src/libexpr/nixexpr.cc
@@ -197,7 +197,22 @@ std::ostream & operator << (std::ostream & str, const Pos & pos)
if (!pos)
str << "undefined position";
else
- str << (format(ANSI_BOLD "%1%" ANSI_NORMAL ":%2%:%3%") % (string) pos.file % pos.line % pos.column).str();
+ {
+ auto f = format(ANSI_BOLD "%1%" ANSI_NORMAL ":%2%:%3%");
+ switch (pos.origin) {
+ case foFile:
+ f % (string) pos.file;
+ break;
+ case foStdin:
+ case foString:
+ f % "(string)";
+ break;
+ default:
+ throw Error("unhandled Pos origin!");
+ }
+ str << (f % pos.line % pos.column).str();
+ }
+
return str;
}
@@ -270,7 +285,7 @@ void ExprVar::bindVars(const StaticEnv & env)
if (withLevel == -1)
throw UndefinedVarError({
.hint = hintfmt("undefined variable '%1%'", name),
- .nixCode = NixCode { .errPos = pos }
+ .errPos = pos
});
fromWith = true;
this->level = withLevel;
diff --git a/src/libexpr/nixexpr.hh b/src/libexpr/nixexpr.hh
index ec6fd3190..e4cbc660f 100644
--- a/src/libexpr/nixexpr.hh
+++ b/src/libexpr/nixexpr.hh
@@ -24,11 +24,12 @@ MakeError(RestrictedPathError, Error);
struct Pos
{
+ FileOrigin origin;
Symbol file;
unsigned int line, column;
- Pos() : line(0), column(0) { };
- Pos(const Symbol & file, unsigned int line, unsigned int column)
- : file(file), line(line), column(column) { };
+ Pos() : origin(foString), line(0), column(0) { };
+ Pos(FileOrigin origin, const Symbol & file, unsigned int line, unsigned int column)
+ : origin(origin), file(file), line(line), column(column) { };
operator bool() const
{
return line != 0;
@@ -238,7 +239,7 @@ struct ExprLambda : Expr
if (!arg.empty() && formals && formals->argNames.find(arg) != formals->argNames.end())
throw ParseError({
.hint = hintfmt("duplicate formal function argument '%1%'", arg),
- .nixCode = NixCode { .errPos = pos }
+ .errPos = pos
});
};
void setName(Symbol & name);
diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y
index 7b28b8509..24b21f7da 100644
--- a/src/libexpr/parser.y
+++ b/src/libexpr/parser.y
@@ -30,7 +30,8 @@ namespace nix {
SymbolTable & symbols;
Expr * result;
Path basePath;
- Symbol path;
+ Symbol file;
+ FileOrigin origin;
ErrorInfo error;
Symbol sLetBody;
ParseData(EvalState & state)
@@ -65,18 +66,17 @@ namespace nix {
static void dupAttr(const AttrPath & attrPath, const Pos & pos, const Pos & prevPos)
{
throw ParseError({
- .hint = hintfmt("attribute '%1%' already defined at %2%",
+ .hint = hintfmt("attribute '%1%' already defined at %2%",
showAttrPath(attrPath), prevPos),
- .nixCode = NixCode { .errPos = pos },
+ .errPos = pos
});
}
-
static void dupAttr(Symbol attr, const Pos & pos, const Pos & prevPos)
{
throw ParseError({
.hint = hintfmt("attribute '%1%' already defined at %2%", attr, prevPos),
- .nixCode = NixCode { .errPos = pos },
+ .errPos = pos
});
}
@@ -148,7 +148,7 @@ static void addFormal(const Pos & pos, Formals * formals, const Formal & formal)
throw ParseError({
.hint = hintfmt("duplicate formal function argument '%1%'",
formal.name),
- .nixCode = NixCode { .errPos = pos },
+ .errPos = pos
});
formals->formals.push_front(formal);
}
@@ -246,7 +246,7 @@ static Expr * stripIndentation(const Pos & pos, SymbolTable & symbols, vector<Ex
static inline Pos makeCurPos(const YYLTYPE & loc, ParseData * data)
{
- return Pos(data->path, loc.first_line, loc.first_column);
+ return Pos(data->origin, data->file, loc.first_line, loc.first_column);
}
#define CUR_POS makeCurPos(*yylocp, data)
@@ -259,7 +259,7 @@ void yyerror(YYLTYPE * loc, yyscan_t scanner, ParseData * data, const char * err
{
data->error = {
.hint = hintfmt(error),
- .nixCode = NixCode { .errPos = makeCurPos(*loc, data) }
+ .errPos = makeCurPos(*loc, data)
};
}
@@ -339,7 +339,7 @@ expr_function
{ if (!$2->dynamicAttrs.empty())
throw ParseError({
.hint = hintfmt("dynamic attributes not allowed in let"),
- .nixCode = NixCode { .errPos = CUR_POS },
+ .errPos = CUR_POS
});
$$ = new ExprLet($2, $4);
}
@@ -419,7 +419,7 @@ expr_simple
if (noURLLiterals)
throw ParseError({
.hint = hintfmt("URL literals are disabled"),
- .nixCode = NixCode { .errPos = CUR_POS }
+ .errPos = CUR_POS
});
$$ = new ExprString(data->symbols.create($1));
}
@@ -492,7 +492,7 @@ attrs
} else
throw ParseError({
.hint = hintfmt("dynamic attributes not allowed in inherit"),
- .nixCode = NixCode { .errPos = makeCurPos(@2, data) },
+ .errPos = makeCurPos(@2, data)
});
}
| { $$ = new AttrPath; }
@@ -569,13 +569,24 @@ formal
namespace nix {
-Expr * EvalState::parse(const char * text,
+Expr * EvalState::parse(const char * text, FileOrigin origin,
const Path & path, const Path & basePath, StaticEnv & staticEnv)
{
yyscan_t scanner;
ParseData data(*this);
+ data.origin = origin;
+ switch (origin) {
+ case foFile:
+ data.file = data.symbols.create(path);
+ break;
+ case foStdin:
+ case foString:
+ data.file = data.symbols.create(text);
+ break;
+ default:
+ assert(false);
+ }
data.basePath = basePath;
- data.path = data.symbols.create(path);
yylex_init(&scanner);
yy_scan_string(text, scanner);
@@ -625,13 +636,13 @@ Expr * EvalState::parseExprFromFile(const Path & path)
Expr * EvalState::parseExprFromFile(const Path & path, StaticEnv & staticEnv)
{
- return parse(readFile(path).c_str(), path, dirOf(path), staticEnv);
+ return parse(readFile(path).c_str(), foFile, path, dirOf(path), staticEnv);
}
Expr * EvalState::parseExprFromString(std::string_view s, const Path & basePath, StaticEnv & staticEnv)
{
- return parse(s.data(), "(string)", basePath, staticEnv);
+ return parse(s.data(), foString, "", basePath, staticEnv);
}
@@ -644,7 +655,7 @@ Expr * EvalState::parseExprFromString(std::string_view s, const Path & basePath)
Expr * EvalState::parseStdin()
{
//Activity act(*logger, lvlTalkative, format("parsing standard input"));
- return parseExprFromString(drainFD(0), absPath("."));
+ return parse(drainFD(0).data(), foStdin, "", absPath("."), staticBaseEnv);
}
@@ -693,7 +704,7 @@ Path EvalState::findFile(SearchPath & searchPath, const string & path, const Pos
? "cannot look up '<%s>' in pure evaluation mode (use '--impure' to override)"
: "file '%s' was not found in the Nix search path (add it using $NIX_PATH or -I)",
path),
- .nixCode = NixCode { .errPos = pos }
+ .errPos = pos
});
}
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index 96c20b227..539a13f30 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -84,7 +84,7 @@ static void prim_scopedImport(EvalState & state, const Pos & pos, Value * * args
} catch (InvalidPathError & e) {
throw EvalError({
.hint = hintfmt("cannot import '%1%', since path '%2%' is not valid", path, e.path),
- .nixCode = NixCode { .errPos = pos }
+ .errPos = pos
});
}
@@ -165,7 +165,7 @@ void prim_importNative(EvalState & state, const Pos & pos, Value * * args, Value
.hint = hintfmt(
"cannot import '%1%', since path '%2%' is not valid",
path, e.path),
- .nixCode = NixCode { .errPos = pos }
+ .errPos = pos
});
}
@@ -203,7 +203,7 @@ void prim_exec(EvalState & state, const Pos & pos, Value * * args, Value & v)
if (count == 0) {
throw EvalError({
.hint = hintfmt("at least one argument to 'exec' required"),
- .nixCode = NixCode { .errPos = pos }
+ .errPos = pos
});
}
PathSet context;
@@ -218,7 +218,7 @@ void prim_exec(EvalState & state, const Pos & pos, Value * * args, Value & v)
throw EvalError({
.hint = hintfmt("cannot execute '%1%', since path '%2%' is not valid",
program, e.path),
- .nixCode = NixCode { .errPos = pos }
+ .errPos = pos
});
}
@@ -227,13 +227,13 @@ void prim_exec(EvalState & state, const Pos & pos, Value * * args, Value & v)
try {
parsed = state.parseExprFromString(output, pos.file);
} catch (Error & e) {
- e.addPrefix(fmt("While parsing the output from '%1%', at %2%\n", program, pos));
+ e.addTrace(pos, "While parsing the output from '%1%'", program);
throw;
}
try {
state.eval(parsed, v);
} catch (Error & e) {
- e.addPrefix(fmt("While evaluating the output from '%1%', at %2%\n", program, pos));
+ e.addTrace(pos, "While evaluating the output from '%1%'", program);
throw;
}
}
@@ -373,7 +373,7 @@ static void prim_genericClosure(EvalState & state, const Pos & pos, Value * * ar
if (startSet == args[0]->attrs->end())
throw EvalError({
.hint = hintfmt("attribute 'startSet' required"),
- .nixCode = NixCode { .errPos = pos }
+ .errPos = pos
});
state.forceList(*startSet->value, pos);
@@ -387,7 +387,7 @@ static void prim_genericClosure(EvalState & state, const Pos & pos, Value * * ar
if (op == args[0]->attrs->end())
throw EvalError({
.hint = hintfmt("attribute 'operator' required"),
- .nixCode = NixCode { .errPos = pos }
+ .errPos = pos
});
state.forceValue(*op->value, pos);
@@ -409,7 +409,7 @@ static void prim_genericClosure(EvalState & state, const Pos & pos, Value * * ar
if (key == e->attrs->end())
throw EvalError({
.hint = hintfmt("attribute 'key' required"),
- .nixCode = NixCode { .errPos = pos }
+ .errPos = pos
});
state.forceValue(*key->value, pos);
@@ -459,7 +459,7 @@ static void prim_addErrorContext(EvalState & state, const Pos & pos, Value * * a
v = *args[1];
} catch (Error & e) {
PathSet context;
- e.addPrefix(format("%1%\n") % state.coerceToString(pos, *args[0], context));
+ e.addTrace(std::nullopt, state.coerceToString(pos, *args[0], context));
throw;
}
}
@@ -544,14 +544,14 @@ static void prim_derivationStrict(EvalState & state, const Pos & pos, Value * *
if (attr == args[0]->attrs->end())
throw EvalError({
.hint = hintfmt("required attribute 'name' missing"),
- .nixCode = NixCode { .errPos = pos }
+ .errPos = pos
});
string drvName;
Pos & posDrvName(*attr->pos);
try {
drvName = state.forceStringNoCtx(*attr->value, pos);
} catch (Error & e) {
- e.addPrefix(fmt("while evaluating the derivation attribute 'name' at %1%:\n", posDrvName));
+ e.addTrace(posDrvName, "while evaluating the derivation attribute 'name'");
throw;
}
@@ -591,7 +591,7 @@ static void prim_derivationStrict(EvalState & state, const Pos & pos, Value * *
else
throw EvalError({
.hint = hintfmt("invalid value '%s' for 'outputHashMode' attribute", s),
- .nixCode = NixCode { .errPos = posDrvName }
+ .errPos = posDrvName
});
};
@@ -601,7 +601,7 @@ static void prim_derivationStrict(EvalState & state, const Pos & pos, Value * *
if (outputs.find(j) != outputs.end())
throw EvalError({
.hint = hintfmt("duplicate derivation output '%1%'", j),
- .nixCode = NixCode { .errPos = posDrvName }
+ .errPos = posDrvName
});
/* !!! Check whether j is a valid attribute
name. */
@@ -611,14 +611,14 @@ static void prim_derivationStrict(EvalState & state, const Pos & pos, Value * *
if (j == "drv")
throw EvalError({
.hint = hintfmt("invalid derivation output name 'drv'" ),
- .nixCode = NixCode { .errPos = posDrvName }
+ .errPos = posDrvName
});
outputs.insert(j);
}
if (outputs.empty())
throw EvalError({
.hint = hintfmt("derivation cannot have an empty set of outputs"),
- .nixCode = NixCode { .errPos = posDrvName }
+ .errPos = posDrvName
});
};
@@ -684,8 +684,9 @@ static void prim_derivationStrict(EvalState & state, const Pos & pos, Value * *
}
} catch (Error & e) {
- e.addPrefix(format("while evaluating the attribute '%1%' of the derivation '%2%' at %3%:\n")
- % key % drvName % posDrvName);
+ e.addTrace(posDrvName,
+ "while evaluating the attribute '%1%' of the derivation '%2%'",
+ key, drvName);
throw;
}
}
@@ -733,20 +734,20 @@ static void prim_derivationStrict(EvalState & state, const Pos & pos, Value * *
if (drv.builder == "")
throw EvalError({
.hint = hintfmt("required attribute 'builder' missing"),
- .nixCode = NixCode { .errPos = posDrvName }
+ .errPos = posDrvName
});
if (drv.platform == "")
throw EvalError({
.hint = hintfmt("required attribute 'system' missing"),
- .nixCode = NixCode { .errPos = posDrvName }
+ .errPos = posDrvName
});
/* Check whether the derivation name is valid. */
if (isDerivation(drvName))
throw EvalError({
.hint = hintfmt("derivation names are not allowed to end in '%s'", drvExtension),
- .nixCode = NixCode { .errPos = posDrvName }
+ .errPos = posDrvName
});
if (outputHash) {
@@ -754,7 +755,7 @@ static void prim_derivationStrict(EvalState & state, const Pos & pos, Value * *
if (outputs.size() != 1 || *(outputs.begin()) != "out")
throw Error({
.hint = hintfmt("multiple outputs are not supported in fixed-output derivations"),
- .nixCode = NixCode { .errPos = posDrvName }
+ .errPos = posDrvName
});
std::optional<HashType> ht = parseHashTypeOpt(outputHashAlgo);
@@ -868,7 +869,7 @@ static void prim_storePath(EvalState & state, const Pos & pos, Value * * args, V
if (!state.store->isInStore(path))
throw EvalError({
.hint = hintfmt("path '%1%' is not in the Nix store", path),
- .nixCode = NixCode { .errPos = pos }
+ .errPos = pos
});
Path path2 = state.store->toStorePath(path);
if (!settings.readOnlyMode)
@@ -889,7 +890,7 @@ static void prim_pathExists(EvalState & state, const Pos & pos, Value * * args,
.hint = hintfmt(
"cannot check the existence of '%1%', since path '%2%' is not valid",
path, e.path),
- .nixCode = NixCode { .errPos = pos }
+ .errPos = pos
});
}
@@ -935,7 +936,7 @@ static void prim_readFile(EvalState & state, const Pos & pos, Value * * args, Va
} catch (InvalidPathError & e) {
throw EvalError({
.hint = hintfmt("cannot read '%1%', since path '%2%' is not valid", path, e.path),
- .nixCode = NixCode { .errPos = pos }
+ .errPos = pos
});
}
string s = readFile(state.checkSourcePath(state.toRealPath(path, context)));
@@ -966,7 +967,7 @@ static void prim_findFile(EvalState & state, const Pos & pos, Value * * args, Va
if (i == v2.attrs->end())
throw EvalError({
.hint = hintfmt("attribute 'path' missing"),
- .nixCode = NixCode { .errPos = pos }
+ .errPos = pos
});
PathSet context;
@@ -977,7 +978,7 @@ static void prim_findFile(EvalState & state, const Pos & pos, Value * * args, Va
} catch (InvalidPathError & e) {
throw EvalError({
.hint = hintfmt("cannot find '%1%', since path '%2%' is not valid", path, e.path),
- .nixCode = NixCode { .errPos = pos }
+ .errPos = pos
});
}
@@ -997,7 +998,7 @@ static void prim_hashFile(EvalState & state, const Pos & pos, Value * * args, Va
if (!ht)
throw Error({
.hint = hintfmt("unknown hash type '%1%'", type),
- .nixCode = NixCode { .errPos = pos }
+ .errPos = pos
});
PathSet context; // discarded
@@ -1016,7 +1017,7 @@ static void prim_readDir(EvalState & state, const Pos & pos, Value * * args, Val
} catch (InvalidPathError & e) {
throw EvalError({
.hint = hintfmt("cannot read '%1%', since path '%2%' is not valid", path, e.path),
- .nixCode = NixCode { .errPos = pos }
+ .errPos = pos
});
}
@@ -1092,7 +1093,7 @@ static void prim_toFile(EvalState &