forked from lix-project/lix
Make queryJSON not bail immediately on an assertion or error
This commit is contained in:
parent
6ff2ce8caf
commit
61f02f7f20
|
@ -911,36 +911,44 @@ static void queryJSON(Globals & globals, vector<DrvInfo> & elems, bool printOutP
|
||||||
{
|
{
|
||||||
JSONObject topObj(cout, true);
|
JSONObject topObj(cout, true);
|
||||||
for (auto & i : elems) {
|
for (auto & i : elems) {
|
||||||
JSONObject pkgObj = topObj.object(i.attrPath);
|
try {
|
||||||
|
if (i.hasFailed()) continue;
|
||||||
|
|
||||||
auto drvName = DrvName(i.queryName());
|
JSONObject pkgObj = topObj.object(i.attrPath);
|
||||||
pkgObj.attr("name", drvName.fullName);
|
|
||||||
pkgObj.attr("pname", drvName.name);
|
|
||||||
pkgObj.attr("version", drvName.version);
|
|
||||||
pkgObj.attr("system", i.querySystem());
|
|
||||||
|
|
||||||
if (printOutPath) {
|
auto drvName = DrvName(i.queryName());
|
||||||
DrvInfo::Outputs outputs = i.queryOutputs();
|
pkgObj.attr("name", drvName.fullName);
|
||||||
JSONObject outputObj = pkgObj.object("outputs");
|
pkgObj.attr("pname", drvName.name);
|
||||||
for (auto & j : outputs) {
|
pkgObj.attr("version", drvName.version);
|
||||||
outputObj.attr(j.first, j.second);
|
pkgObj.attr("system", i.querySystem());
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (printMeta) {
|
if (printOutPath) {
|
||||||
JSONObject metaObj = pkgObj.object("meta");
|
DrvInfo::Outputs outputs = i.queryOutputs();
|
||||||
StringSet metaNames = i.queryMetaNames();
|
JSONObject outputObj = pkgObj.object("outputs");
|
||||||
for (auto & j : metaNames) {
|
for (auto & j : outputs) {
|
||||||
auto placeholder = metaObj.placeholder(j);
|
outputObj.attr(j.first, j.second);
|
||||||
Value * v = i.queryMeta(j);
|
|
||||||
if (!v) {
|
|
||||||
printError("derivation '%s' has invalid meta attribute '%s'", i.queryName(), j);
|
|
||||||
placeholder.write(nullptr);
|
|
||||||
} else {
|
|
||||||
PathSet context;
|
|
||||||
printValueAsJSON(*globals.state, true, *v, noPos, placeholder, context);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (printMeta) {
|
||||||
|
JSONObject metaObj = pkgObj.object("meta");
|
||||||
|
StringSet metaNames = i.queryMetaNames();
|
||||||
|
for (auto & j : metaNames) {
|
||||||
|
auto placeholder = metaObj.placeholder(j);
|
||||||
|
Value * v = i.queryMeta(j);
|
||||||
|
if (!v) {
|
||||||
|
printError("derivation '%s' has invalid meta attribute '%s'", i.queryName(), j);
|
||||||
|
placeholder.write(nullptr);
|
||||||
|
} else {
|
||||||
|
PathSet context;
|
||||||
|
printValueAsJSON(*globals.state, true, *v, noPos, placeholder, context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (AssertionError & e) {
|
||||||
|
printMsg(lvlTalkative, "skipping derivation named '%1%' which gives an assertion failure", i.queryName());
|
||||||
|
} catch (Error & e) {
|
||||||
|
printMsg(lvlError, "skipping derivation named '%1%' which gives an error '%2%'", i.queryName(), e.msg());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue