mirror of
https://github.com/NixOS/nix.git
synced 2024-11-23 07:12:27 +00:00
* Some better error messages.
This commit is contained in:
parent
1d694eef4c
commit
dd300fb48d
@ -54,7 +54,7 @@ void queryAllAttrs(Expr e, ATermMap & attrs, bool withPos)
|
|||||||
{
|
{
|
||||||
ATermList bnds;
|
ATermList bnds;
|
||||||
if (!matchAttrs(e, bnds))
|
if (!matchAttrs(e, bnds))
|
||||||
throw TypeError("attribute set expected");
|
throw TypeError(format("value is %1% while an attribute set was expected") % showType(e));
|
||||||
|
|
||||||
for (ATermIterator i(bnds); i; ++i) {
|
for (ATermIterator i(bnds); i; ++i) {
|
||||||
ATerm name;
|
ATerm name;
|
||||||
@ -77,7 +77,7 @@ Expr queryAttr(Expr e, const string & name, ATerm & pos)
|
|||||||
{
|
{
|
||||||
ATermList bnds;
|
ATermList bnds;
|
||||||
if (!matchAttrs(e, bnds))
|
if (!matchAttrs(e, bnds))
|
||||||
throw TypeError("attribute set expected");
|
throw TypeError(format("value is %1% while an attribute set was expected") % showType(e));
|
||||||
|
|
||||||
for (ATermIterator i(bnds); i; ++i) {
|
for (ATermIterator i(bnds); i; ++i) {
|
||||||
ATerm name2, pos2;
|
ATerm name2, pos2;
|
||||||
|
@ -130,12 +130,19 @@ static Expr primDerivationStrict(EvalState & state, const ATermVector & args)
|
|||||||
queryAllAttrs(evalExpr(state, args[0]), attrs, true);
|
queryAllAttrs(evalExpr(state, args[0]), attrs, true);
|
||||||
|
|
||||||
/* Figure out the name already (for stack backtraces). */
|
/* Figure out the name already (for stack backtraces). */
|
||||||
|
ATerm posDrvName;
|
||||||
Expr eDrvName = attrs.get(toATerm("name"));
|
Expr eDrvName = attrs.get(toATerm("name"));
|
||||||
if (!eDrvName)
|
if (!eDrvName)
|
||||||
throw EvalError("required attribute `name' missing");
|
throw EvalError("required attribute `name' missing");
|
||||||
ATerm posDrvName;
|
|
||||||
if (!matchAttrRHS(eDrvName, eDrvName, posDrvName)) abort();
|
if (!matchAttrRHS(eDrvName, eDrvName, posDrvName)) abort();
|
||||||
string drvName = evalStringNoCtx(state, eDrvName);
|
string drvName;
|
||||||
|
try {
|
||||||
|
drvName = evalStringNoCtx(state, eDrvName);
|
||||||
|
} catch (Error & e) {
|
||||||
|
e.addPrefix(format("while evaluating the derivation attribute `name' at %1%:\n")
|
||||||
|
% showPos(posDrvName));
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
/* Build the derivation expression by processing the attributes. */
|
/* Build the derivation expression by processing the attributes. */
|
||||||
Derivation drv;
|
Derivation drv;
|
||||||
@ -190,7 +197,7 @@ static Expr primDerivationStrict(EvalState & state, const ATermVector & args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (Error & e) {
|
} catch (Error & e) {
|
||||||
e.addPrefix(format("while processing the derivation attribute `%1%' at %2%:\n")
|
e.addPrefix(format("while evaluating the derivation attribute `%1%' at %2%:\n")
|
||||||
% key % showPos(pos));
|
% key % showPos(pos));
|
||||||
e.addPrefix(format("while instantiating the derivation named `%1%' at %2%:\n")
|
e.addPrefix(format("while instantiating the derivation named `%1%' at %2%:\n")
|
||||||
% drvName % showPos(posDrvName));
|
% drvName % showPos(posDrvName));
|
||||||
|
Loading…
Reference in New Issue
Block a user