Skip to content

Commit e272fbb

Browse files
authored
Merge pull request #41 from msiuts/improve_error_handling
Improve error handling
2 parents 3df1157 + 037fea6 commit e272fbb

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

exporter/http.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ func paginateTargets(targets []string, token string) []string {
6060
resp, err := getHTTPResponse(url, token)
6161
if err != nil {
6262
log.Errorf("Error retrieving Link headers, Error: %s", err)
63+
continue
6364
}
6465

6566
if resp.Header["Link"] != nil {
@@ -95,16 +96,14 @@ func getResponse(url string, token string, ch chan<- *Response) error {
9596
log.Infof("Fetching %s \n", url)
9697

9798
resp, err := getHTTPResponse(url, token) // do this earlier
98-
9999
if err != nil {
100-
return fmt.Errorf("Error converting body to byte array: %v", err)
100+
return fmt.Errorf("Error fetching http response: %v", err)
101101
}
102+
defer resp.Body.Close()
103+
102104

103105
// Read the body to a byte array so it can be used elsewhere
104106
body, err := ioutil.ReadAll(resp.Body)
105-
106-
defer resp.Body.Close()
107-
108107
if err != nil {
109108
return fmt.Errorf("Error converting body to byte array: %v", err)
110109
}

0 commit comments

Comments
 (0)