Merge pull request #5922 from fzakaria/fzakaria/json-ignore-assertion

Add try/catch to queryJSON for assertion and errors
This commit is contained in:
Eelco Dolstra 2022-01-25 12:44:20 +01:00 committed by GitHub
commit a04a66c196
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 25 deletions

4
.gitignore vendored
View file

@ -120,3 +120,7 @@ GTAGS
compile_commands.json
nix-rust/target
result
.vscode/

View file

@ -911,6 +911,9 @@ static void queryJSON(Globals & globals, vector<DrvInfo> & elems, bool printOutP
{
JSONObject topObj(cout, true);
for (auto & i : elems) {
try {
if (i.hasFailed()) continue;
JSONObject pkgObj = topObj.object(i.attrPath);
auto drvName = DrvName(i.queryName());
@ -942,6 +945,12 @@ static void queryJSON(Globals & globals, vector<DrvInfo> & elems, bool printOutP
}
}
}
} catch (AssertionError & e) {
printMsg(lvlTalkative, "skipping derivation named '%1%' which gives an assertion failure", i.queryName());
} catch (Error & e) {
e.addTrace(std::nullopt, "while querying the derivation named '%1%'", i.queryName());
throw;
}
}
}