Skip to content

Commit

Permalink
Print fact gathering error in facts gather cmd call (#304)
Browse files Browse the repository at this point in the history
  • Loading branch information
arbulu89 authored Nov 30, 2023
1 parent 48be5f5 commit f4344f0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cmd/facts.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,20 @@ func gather(*cobra.Command, []string) {

value, err := g.Gather(factRequest)
if err != nil {
log.Errorf("Error gathering fact \"%s\" with argument \"%s\"", gatherer, argument)
cleanupAndFatal(err)
}

if len(value) != 1 {
log.Printf("No value gathered for \"%s\" with argument \"%s\"", gatherer, argument)
return
}

if value[0].Error != nil {
log.Errorf("Error gathering fact \"%s\" with argument \"%s\"", gatherer, argument)
cleanupAndFatal(value[0].Error)
}

result, err := value[0].Prettify()
if err != nil {
cleanupAndFatal(err)
Expand Down

0 comments on commit f4344f0

Please sign in to comment.