Skip to content

Commit

Permalink
Log an error if a name token has no matches
Browse files Browse the repository at this point in the history
  • Loading branch information
tmck-code committed Mar 22, 2022
1 parent 3f8c003 commit e36eb6a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pokesay.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,12 @@ func main() {
}

if args.NameToken != "" {
matches := collectPokemonWithToken(pokemon, args.NameToken)
if len(matches) == 0 {
log.Fatal(fmt.Sprintf("Not a valid name: '%s'", args.NameToken))
}
printSpeechBubble(bufio.NewScanner(os.Stdin), args)
printPokemon(chooseRandomPokemon(collectPokemonWithToken(pokemon, args.NameToken)))
printPokemon(chooseRandomPokemon(matches))
os.Exit(0)
}

Expand Down

0 comments on commit e36eb6a

Please sign in to comment.