diff options
author | Shay Bergmann <shaybergmann@gmail.com> | 2021-10-25 21:13:35 +0000 |
---|---|---|
committer | Shay Bergmann <shaybergmann@gmail.com> | 2021-10-25 21:17:52 +0000 |
commit | ba81e871b2b3a034f3e2eaa5242c98e2f253cdd5 (patch) | |
tree | 665bbd5b319568946f1681821f704b6db5eb650f /src/nix-instantiate/nix-instantiate.cc | |
parent | 4a2b7cc68c7d11ec126bc412ffea838e629345af (diff) |
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");
```
Diffstat (limited to 'src/nix-instantiate/nix-instantiate.cc')
-rw-r--r-- | src/nix-instantiate/nix-instantiate.cc | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/nix-instantiate/nix-instantiate.cc b/src/nix-instantiate/nix-instantiate.cc index 25d0fa3ba..ac48682c7 100644 --- a/src/nix-instantiate/nix-instantiate.cc +++ b/src/nix-instantiate/nix-instantiate.cc @@ -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; |