mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-25 23:36:16 +02:00
Print error messages but not traces
This makes output of values that include errors much cleaner. Before: ``` 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!»; } ``` After: ``` nix-repl> { err = builtins.throw "uh oh!"; } { err = «error: uh oh!»; } ``` But if the whole expression throws an error, source locations and (if applicable) a stack trace are printed, 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! ```
This commit is contained in:
parent
49cf090cb2
commit
c5d525cd84
2 changed files with 5 additions and 41 deletions
|
@ -409,7 +409,7 @@ private:
|
||||||
{
|
{
|
||||||
if (options.ansiColors)
|
if (options.ansiColors)
|
||||||
output << ANSI_RED;
|
output << ANSI_RED;
|
||||||
output << "«" << e.msg() << "»";
|
output << "«error: " << filterANSIEscapes(e.info().msg.str(), true) << "»";
|
||||||
if (options.ansiColors)
|
if (options.ansiColors)
|
||||||
output << ANSI_NORMAL;
|
output << ANSI_NORMAL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -460,19 +460,7 @@ TEST_F(ValuePrintingTests, ansiColorsError)
|
||||||
|
|
||||||
test(vError,
|
test(vError,
|
||||||
ANSI_RED
|
ANSI_RED
|
||||||
"«"
|
"«error: uh oh!»"
|
||||||
ANSI_RED
|
|
||||||
"error:"
|
|
||||||
ANSI_NORMAL
|
|
||||||
"\n … while calling the '"
|
|
||||||
ANSI_MAGENTA
|
|
||||||
"throw"
|
|
||||||
ANSI_NORMAL
|
|
||||||
"' builtin\n\n "
|
|
||||||
ANSI_RED
|
|
||||||
"error:"
|
|
||||||
ANSI_NORMAL
|
|
||||||
" uh oh!»"
|
|
||||||
ANSI_NORMAL,
|
ANSI_NORMAL,
|
||||||
PrintOptions {
|
PrintOptions {
|
||||||
.ansiColors = true,
|
.ansiColors = true,
|
||||||
|
@ -501,19 +489,7 @@ TEST_F(ValuePrintingTests, ansiColorsDerivationError)
|
||||||
test(vAttrs,
|
test(vAttrs,
|
||||||
"{ drvPath = "
|
"{ drvPath = "
|
||||||
ANSI_RED
|
ANSI_RED
|
||||||
"«"
|
"«error: uh oh!»"
|
||||||
ANSI_RED
|
|
||||||
"error:"
|
|
||||||
ANSI_NORMAL
|
|
||||||
"\n … while calling the '"
|
|
||||||
ANSI_MAGENTA
|
|
||||||
"throw"
|
|
||||||
ANSI_NORMAL
|
|
||||||
"' builtin\n\n "
|
|
||||||
ANSI_RED
|
|
||||||
"error:"
|
|
||||||
ANSI_NORMAL
|
|
||||||
" uh oh!»"
|
|
||||||
ANSI_NORMAL
|
ANSI_NORMAL
|
||||||
"; type = "
|
"; type = "
|
||||||
ANSI_MAGENTA
|
ANSI_MAGENTA
|
||||||
|
@ -527,19 +503,7 @@ TEST_F(ValuePrintingTests, ansiColorsDerivationError)
|
||||||
|
|
||||||
test(vAttrs,
|
test(vAttrs,
|
||||||
ANSI_RED
|
ANSI_RED
|
||||||
"«"
|
"«error: uh oh!»"
|
||||||
ANSI_RED
|
|
||||||
"error:"
|
|
||||||
ANSI_NORMAL
|
|
||||||
"\n … while calling the '"
|
|
||||||
ANSI_MAGENTA
|
|
||||||
"throw"
|
|
||||||
ANSI_NORMAL
|
|
||||||
"' builtin\n\n "
|
|
||||||
ANSI_RED
|
|
||||||
"error:"
|
|
||||||
ANSI_NORMAL
|
|
||||||
" uh oh!»"
|
|
||||||
ANSI_NORMAL,
|
ANSI_NORMAL,
|
||||||
PrintOptions {
|
PrintOptions {
|
||||||
.ansiColors = true,
|
.ansiColors = true,
|
||||||
|
@ -560,7 +524,7 @@ TEST_F(ValuePrintingTests, ansiColorsAssert)
|
||||||
state.mkThunk_(v, &expr);
|
state.mkThunk_(v, &expr);
|
||||||
|
|
||||||
test(v,
|
test(v,
|
||||||
ANSI_RED "«" ANSI_RED "error:" ANSI_NORMAL " assertion '" ANSI_MAGENTA "false" ANSI_NORMAL "' failed»" ANSI_NORMAL,
|
ANSI_RED "«error: assertion 'false' failed»" ANSI_NORMAL,
|
||||||
PrintOptions {
|
PrintOptions {
|
||||||
.ansiColors = true,
|
.ansiColors = true,
|
||||||
.force = true
|
.force = true
|
||||||
|
|
Loading…
Reference in a new issue