mirror of
https://github.com/NixOS/nix
synced 2025-06-28 09:31:16 +02:00
toJSON: report error position for fancier output
Given flake: ```nix { description = "nix json error provenance"; inputs = {}; outputs = { self }: { jsonFunction = _: "function"; json = builtins.toJSON (_: "function"); }; } ``` - Before: ```console ❯ nix eval --json .#jsonFunction error: cannot convert a function to JSON ``` - After: ```console ❯ nix eval --json .#jsonFunction error: cannot convert a function to JSON at /nix/store/b7imf1c2j4jnkg3ys7fsfbj02s5j0i4f-source/testflake/flake.nix:4:5: 3| outputs = { self }: { 4| jsonFunction = _: "function"; | ^ 5| json = builtins.toJSON (_: "function"); ```
This commit is contained in:
parent
4a2b7cc68c
commit
ba81e871b2
6 changed files with 22 additions and 16 deletions
|
@ -52,7 +52,7 @@ void processExpr(EvalState & state, const Strings & attrPaths,
|
|||
if (output == okXML)
|
||||
printValueAsXML(state, strict, location, vRes, std::cout, context);
|
||||
else if (output == okJSON)
|
||||
printValueAsJSON(state, strict, vRes, std::cout, context);
|
||||
printValueAsJSON(state, strict, vRes, noPos, std::cout, context);
|
||||
else {
|
||||
if (strict) state.forceValueDeep(vRes);
|
||||
std::cout << vRes << std::endl;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue