aboutsummaryrefslogtreecommitdiff
path: root/doc/manual
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-03-08 06:50:31 +0100
committereldritch horrors <pennae@lix.systems>2024-03-09 03:37:35 -0700
commit7673312ccc179825033e4458604ddd2e9ae8d162 (patch)
tree7f81aef04abeef0211030c64f186da3cd0638498 /doc/manual
parentc8649239280360877a33c7aacf14889cb441f643 (diff)
Merge pull request #9928 from 9999years/error-messages-in-nix-repl
Improve error printing in `nix repl` (cherry picked from commit a8050d9b83052e4b5c52bf2d116381aedec3a93e) Change-Id: I588f92d1dd4c546c98788b71403cc034f5e7129a
Diffstat (limited to 'doc/manual')
-rw-r--r--doc/manual/rl-next/better-errors-in-nix-repl.md40
1 files changed, 40 insertions, 0 deletions
diff --git a/doc/manual/rl-next/better-errors-in-nix-repl.md b/doc/manual/rl-next/better-errors-in-nix-repl.md
new file mode 100644
index 000000000..4deaa8c70
--- /dev/null
+++ b/doc/manual/rl-next/better-errors-in-nix-repl.md
@@ -0,0 +1,40 @@
+---
+synopsis: Concise error printing in `nix repl`
+prs: 9928
+---
+
+Previously, if an element of a list or attribute set threw an error while
+evaluating, `nix repl` would print the entire error (including source location
+information) inline. This output was clumsy and difficult to parse:
+
+```
+nix-repl> { err = builtins.throw "uh oh!"; }
+{ err = «error:
+ … while calling the 'throw' builtin
+ at «string»:1:9:
+ 1| { err = builtins.throw "uh oh!"; }
+ | ^
+
+ error: uh oh!»; }
+```
+
+Now, only the error message is displayed, making the output much more readable.
+```
+nix-repl> { err = builtins.throw "uh oh!"; }
+{ err = «error: uh oh!»; }
+```
+
+However, if the whole expression being evaluated throws an error, source
+locations and (if applicable) a stack trace are printed, just like you'd expect:
+
+```
+nix-repl> builtins.throw "uh oh!"
+error:
+ … while calling the 'throw' builtin
+ at «string»:1:1:
+ 1| builtins.throw "uh oh!"
+ | ^
+
+ error: uh oh!
+```
+