mirror of
https://github.com/NixOS/nix
synced 2025-06-28 09:31:16 +02:00
Merge branch 'errors-phase-2' of https://github.com/bburdette/nix
This commit is contained in:
commit
7a77762961
81 changed files with 1857 additions and 1010 deletions
|
@ -146,7 +146,11 @@ static void prim_appendContext(EvalState & state, const Pos & pos, Value * * arg
|
|||
auto sAllOutputs = state.symbols.create("allOutputs");
|
||||
for (auto & i : *args[1]->attrs) {
|
||||
if (!state.store->isStorePath(i.name))
|
||||
throw EvalError("Context key '%s' is not a store path, at %s", i.name, i.pos);
|
||||
throw EvalError(
|
||||
ErrorInfo {
|
||||
.hint = hintfmt("Context key '%s' is not a store path", i.name),
|
||||
.nixCode = NixCode { .errPos = *i.pos }
|
||||
});
|
||||
if (!settings.readOnlyMode)
|
||||
state.store->ensurePath(state.store->parseStorePath(i.name));
|
||||
state.forceAttrs(*i.value, *i.pos);
|
||||
|
@ -160,7 +164,11 @@ static void prim_appendContext(EvalState & state, const Pos & pos, Value * * arg
|
|||
if (iter != i.value->attrs->end()) {
|
||||
if (state.forceBool(*iter->value, *iter->pos)) {
|
||||
if (!isDerivation(i.name)) {
|
||||
throw EvalError("Tried to add all-outputs context of %s, which is not a derivation, to a string, at %s", i.name, i.pos);
|
||||
throw EvalError(
|
||||
ErrorInfo {
|
||||
.hint = hintfmt("Tried to add all-outputs context of %s, which is not a derivation, to a string", i.name),
|
||||
.nixCode = NixCode { .errPos = *i.pos }
|
||||
});
|
||||
}
|
||||
context.insert("=" + string(i.name));
|
||||
}
|
||||
|
@ -170,7 +178,11 @@ static void prim_appendContext(EvalState & state, const Pos & pos, Value * * arg
|
|||
if (iter != i.value->attrs->end()) {
|
||||
state.forceList(*iter->value, *iter->pos);
|
||||
if (iter->value->listSize() && !isDerivation(i.name)) {
|
||||
throw EvalError("Tried to add derivation output context of %s, which is not a derivation, to a string, at %s", i.name, i.pos);
|
||||
throw EvalError(
|
||||
ErrorInfo {
|
||||
.hint = hintfmt("Tried to add derivation output context of %s, which is not a derivation, to a string", i.name),
|
||||
.nixCode = NixCode { .errPos = *i.pos }
|
||||
});
|
||||
}
|
||||
for (unsigned int n = 0; n < iter->value->listSize(); ++n) {
|
||||
auto name = state.forceStringNoCtx(*iter->value->listElems()[n], *iter->pos);
|
||||
|
|
|
@ -35,11 +35,19 @@ static void prim_fetchGit(EvalState & state, const Pos & pos, Value * * args, Va
|
|||
else if (n == "submodules")
|
||||
fetchSubmodules = state.forceBool(*attr.value, *attr.pos);
|
||||
else
|
||||
throw EvalError("unsupported argument '%s' to 'fetchGit', at %s", attr.name, *attr.pos);
|
||||
throw EvalError(
|
||||
ErrorInfo {
|
||||
.hint = hintfmt("unsupported argument '%s' to 'fetchGit'", attr.name),
|
||||
.nixCode = NixCode { .errPos = *attr.pos }
|
||||
});
|
||||
}
|
||||
|
||||
if (url.empty())
|
||||
throw EvalError(format("'url' argument required, at %1%") % pos);
|
||||
throw EvalError(
|
||||
ErrorInfo {
|
||||
.hint = hintfmt("'url' argument required"),
|
||||
.nixCode = NixCode { .errPos = pos }
|
||||
});
|
||||
|
||||
} else
|
||||
url = state.coerceToString(pos, *args[0], context, false, false);
|
||||
|
|
|
@ -38,11 +38,19 @@ static void prim_fetchMercurial(EvalState & state, const Pos & pos, Value * * ar
|
|||
else if (n == "name")
|
||||
name = state.forceStringNoCtx(*attr.value, *attr.pos);
|
||||
else
|
||||
throw EvalError("unsupported argument '%s' to 'fetchMercurial', at %s", attr.name, *attr.pos);
|
||||
throw EvalError(
|
||||
ErrorInfo {
|
||||
.hint = hintfmt("unsupported argument '%s' to 'fetchMercurial'", attr.name),
|
||||
.nixCode = NixCode { .errPos = *attr.pos }
|
||||
});
|
||||
}
|
||||
|
||||
if (url.empty())
|
||||
throw EvalError(format("'url' argument required, at %1%") % pos);
|
||||
throw EvalError(
|
||||
ErrorInfo {
|
||||
.hint = hintfmt("'url' argument required"),
|
||||
.nixCode = NixCode { .errPos = pos }
|
||||
});
|
||||
|
||||
} else
|
||||
url = state.coerceToString(pos, *args[0], context, false, false);
|
||||
|
|
|
@ -66,7 +66,11 @@ static void prim_fetchTree(EvalState & state, const Pos & pos, Value * * args, V
|
|||
}
|
||||
|
||||
if (!attrs.count("type"))
|
||||
throw Error("attribute 'type' is missing in call to 'fetchTree', at %s", pos);
|
||||
throw Error(
|
||||
ErrorInfo {
|
||||
.hint = hintfmt("attribute 'type' is missing in call to 'fetchTree'"),
|
||||
.nixCode = NixCode { .errPos = pos }
|
||||
});
|
||||
|
||||
input = fetchers::inputFromAttrs(attrs);
|
||||
} else
|
||||
|
@ -107,13 +111,20 @@ static void fetch(EvalState & state, const Pos & pos, Value * * args, Value & v,
|
|||
else if (n == "name")
|
||||
name = state.forceStringNoCtx(*attr.value, *attr.pos);
|
||||
else
|
||||
throw EvalError("unsupported argument '%s' to '%s', at %s",
|
||||
attr.name, who, *attr.pos);
|
||||
}
|
||||
throw EvalError(
|
||||
ErrorInfo {
|
||||
.hint = hintfmt("unsupported argument '%s' to '%s'",
|
||||
attr.name, who),
|
||||
.nixCode = NixCode { .errPos = *attr.pos }
|
||||
});
|
||||
}
|
||||
|
||||
if (!url)
|
||||
throw EvalError("'url' argument required, at %s", pos);
|
||||
|
||||
throw EvalError(
|
||||
ErrorInfo {
|
||||
.hint = hintfmt("'url' argument required"),
|
||||
.nixCode = NixCode { .errPos = pos }
|
||||
});
|
||||
} else
|
||||
url = state.forceStringNoCtx(*args[0], pos);
|
||||
|
||||
|
|
|
@ -81,7 +81,11 @@ static void prim_fromTOML(EvalState & state, const Pos & pos, Value * * args, Va
|
|||
try {
|
||||
visit(v, parser(tomlStream).parse());
|
||||
} catch (std::runtime_error & e) {
|
||||
throw EvalError("while parsing a TOML string at %s: %s", pos, e.what());
|
||||
throw EvalError(
|
||||
ErrorInfo {
|
||||
.hint = hintfmt("while parsing a TOML string: %s", e.what()),
|
||||
.nixCode = NixCode { .errPos = pos }
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue