lib.fileset: Improved error for unsupported coercion values

This commit is contained in:
Silvan Mosberger 2023-10-16 15:49:53 +02:00
parent 34459dd142
commit 7247ec07ba
2 changed files with 4 additions and 4 deletions

View file

@ -172,11 +172,11 @@ rec {
else if ! isPath value then else if ! isPath value then
if isStringLike value then if isStringLike value then
throw '' throw ''
${context} ("${toString value}") is a string-like value, but it should be a path instead. ${context} ("${toString value}") is a string-like value, but it should be a file set or a path instead.
Paths represented as strings are not supported by `lib.fileset`, use `lib.sources` or derivations instead.'' Paths represented as strings are not supported by `lib.fileset`, use `lib.sources` or derivations instead.''
else else
throw '' throw ''
${context} is of type ${typeOf value}, but it should be a path instead.'' ${context} is of type ${typeOf value}, but it should be a file set or a path instead.''
else if ! pathExists value then else if ! pathExists value then
throw '' throw ''
${context} (${toString value}) does not exist.'' ${context} (${toString value}) does not exist.''

View file

@ -355,8 +355,8 @@ expectFailure 'toSource { root = ./a; fileset = ./.; }' 'lib.fileset.toSource: `
rm -rf * rm -rf *
# Path coercion only works for paths # Path coercion only works for paths
expectFailure 'toSource { root = ./.; fileset = 10; }' 'lib.fileset.toSource: `fileset` is of type int, but it should be a path instead.' expectFailure 'toSource { root = ./.; fileset = 10; }' 'lib.fileset.toSource: `fileset` is of type int, but it should be a file set or a path instead.'
expectFailure 'toSource { root = ./.; fileset = "/some/path"; }' 'lib.fileset.toSource: `fileset` \("/some/path"\) is a string-like value, but it should be a path instead. expectFailure 'toSource { root = ./.; fileset = "/some/path"; }' 'lib.fileset.toSource: `fileset` \("/some/path"\) is a string-like value, but it should be a file set or a path instead.
\s*Paths represented as strings are not supported by `lib.fileset`, use `lib.sources` or derivations instead.' \s*Paths represented as strings are not supported by `lib.fileset`, use `lib.sources` or derivations instead.'
# Path coercion errors for non-existent paths # Path coercion errors for non-existent paths