Skip to content

Commit

Permalink
Check for errors before using response
Browse files Browse the repository at this point in the history
  • Loading branch information
lamaral committed Aug 23, 2023
1 parent be45c2a commit 276694b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions command/ripeatlas/traceroute.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ func (c *tracerouteCommand) traceroute(match matcher.Result, message msg.Message

client := http.Client{Timeout: 240 * time.Second}
response, err = client.Get(subscribeURL)
if err != nil {
c.ReplyError(message, fmt.Errorf("error when unsubscribing to results stream: %w", err))
log.Errorf("error when unsubscribing to results stream: %s", err)
return
}
defer response.Body.Close()
fileScanner := bufio.NewScanner(response.Body)
fileScanner.Split(bufio.ScanLines)
Expand Down

0 comments on commit 276694b

Please sign in to comment.