-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Print the value in
error: cannot coerce
messages
This extends the `error: cannot coerce a TYPE to a string` message to print the value that could not be coerced. This helps with debugging by making it easier to track down where the value is being produced from, especially in errors with deep or unhelpful stack traces.
- Loading branch information
Showing
14 changed files
with
168 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
synopsis: Coercion errors include the failing value | ||
issues: #561 | ||
prs: #9754 | ||
--- | ||
|
||
The `error: cannot coerce a <TYPE> to a string` message now includes the value | ||
which caused the error. | ||
|
||
Before: | ||
|
||
``` | ||
error: cannot coerce a set to a string | ||
``` | ||
|
||
After: | ||
|
||
``` | ||
error: cannot coerce a set to a string: { aesSupport = «thunk»; | ||
avx2Support = «thunk»; avx512Support = «thunk»; avxSupport = «thunk»; | ||
canExecute = «thunk»; config = «thunk»; darwinArch = «thunk»; darwinMinVersion | ||
= «thunk»; darwinMinVersionVariable = «thunk»; darwinPlatform = «thunk»; «84 | ||
attributes elided»} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
#include "print-ambiguous.hh" | ||
#include "print.hh" | ||
#include "signals.hh" | ||
#include "eval.hh" | ||
|
||
namespace nix { | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
let | ||
contentAddressedByDefault = builtins.getEnv "NIX_TESTS_CA_BY_DEFAULT" == "1"; | ||
caArgs = if contentAddressedByDefault then { | ||
__contentAddressed = true; | ||
outputHashMode = "recursive"; | ||
outputHashAlgo = "sha256"; | ||
} else {}; | ||
in | ||
|
||
rec { | ||
shell = "@bash@"; | ||
|
||
path = "@coreutils@"; | ||
|
||
system = "@system@"; | ||
|
||
shared = builtins.getEnv "_NIX_TEST_SHARED"; | ||
|
||
mkDerivation = args: | ||
derivation ({ | ||
inherit system; | ||
builder = shell; | ||
args = ["-e" args.builder or (builtins.toFile "builder-${args.name}.sh" '' | ||
if [ -e "$NIX_ATTRS_SH_FILE" ]; then source $NIX_ATTRS_SH_FILE; fi; | ||
eval "$buildCommand" | ||
'')]; | ||
PATH = path; | ||
} // caArgs // removeAttrs args ["builder" "meta"]) | ||
// { meta = args.meta or {}; }; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
let | ||
contentAddressedByDefault = builtins.getEnv "NIX_TESTS_CA_BY_DEFAULT" == "1"; | ||
caArgs = if contentAddressedByDefault then { | ||
__contentAddressed = true; | ||
outputHashMode = "recursive"; | ||
outputHashAlgo = "sha256"; | ||
} else {}; | ||
in | ||
|
||
rec { | ||
shell = "@bash@"; | ||
|
||
path = "@coreutils@"; | ||
|
||
system = "@system@"; | ||
|
||
shared = builtins.getEnv "_NIX_TEST_SHARED"; | ||
|
||
mkDerivation = args: | ||
derivation ({ | ||
inherit system; | ||
builder = shell; | ||
args = ["-e" args.builder or (builtins.toFile "builder-${args.name}.sh" '' | ||
if [ -e "$NIX_ATTRS_SH_FILE" ]; then source $NIX_ATTRS_SH_FILE; fi; | ||
eval "$buildCommand" | ||
'')]; | ||
PATH = path; | ||
} // caArgs // removeAttrs args ["builder" "meta"]) | ||
// { meta = args.meta or {}; }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.