Skip to content

Commit

Permalink
filecontent mapper: Handle error from directory
Browse files Browse the repository at this point in the history
If we couldn't read because the source is a directory,
override the original error message.
  • Loading branch information
abhinav committed Dec 10, 2023
1 parent ca7d762 commit 404418a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,9 @@ func fileContentMapper(r *Registry) MapperFunc {
data, err = ioutil.ReadAll(os.Stdin)
}
if err != nil {
if info, statErr := os.Stat(path); statErr == nil && info.IsDir() {
return fmt.Errorf("%q exists but is a directory: %w", path, err)
}
return err
}
target.SetBytes(data)
Expand Down

0 comments on commit 404418a

Please sign in to comment.