frames manually added with `addErrorContext` are generally a lot more useful/informative to the average user than other frames, esp. in the module system, which can create much better error messages than we can. however, before this change, frames from addErrorContext were truncated by default if they weren't in the first 3 frames, so they were basically useless (with `--show-trace`, you're dredging through 250 frames of module shenanigans just to spot one singular line). this change also removes the frames for _the call to_ `addErrorContext`, which is just pure noise. the way this change is done hopefully leaves a bit of space for future similar changes to error printing, by introducing a new `TraceKind` enum that can be used to categorize traces (i haven't done that in this CL because that would be a pretty herculean task, given all the calls to `BaseError::addTrace` in the codebase, and we probably want to be careful about what categories we choose). the actual printing code could definitely be improved tho... (e.g. by iterating twice through the trace stack instead to first pick out the most important traces and _then_ printing less "important" traces if there's space left) Change-Id: I52acc52f231991a9f2309d9cecae362397c6888c
25 lines
660 B
Plaintext
25 lines
660 B
Plaintext
error:
|
|
… computing fib(4)
|
|
|
|
… while calling the 'add' builtin
|
|
at /pwd/in.nix:7:8:
|
|
6| # note: we use builtins.add explicitly because it creates more frames than (+)
|
|
7| (builtins.add (fib (n - 1)) (fib (n - 2)));
|
|
| ^
|
|
8| in
|
|
|
|
… computing fib(3)
|
|
|
|
… computing fib(2)
|
|
|
|
… computing fib(1)
|
|
|
|
(stack trace truncated; use '--show-trace' to show the full trace)
|
|
|
|
error: assertion failed
|
|
at /pwd/in.nix:3:5:
|
|
2| fib = n:
|
|
3| assert n > 0;
|
|
| ^
|
|
4| builtins.addErrorContext
|