Skip to content

Commit 4c6396f

Browse files
Joe MonaghanJoe Monaghan
authored andcommitted
catch rate limit exceeded
1 parent 54bddeb commit 4c6396f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

exporter/http.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import (
1212
"github.com/tomnomnom/linkheader"
1313
)
1414

15+
// RateLimitExceededStatus is the status response from github when the rate limit is exceeded.
16+
const RateLimitExceededStatus = "403 rate limit exceeded"
17+
1518
func asyncHTTPGets(targets []string, token string) ([]*Response, error) {
1619
// Expand targets by following GitHub pagination links
1720
targets = paginateTargets(targets, token)
@@ -141,5 +144,10 @@ func getHTTPResponse(url string, token string) (*http.Response, error) {
141144
return nil, err
142145
}
143146

147+
// check rate limit exceeded.
148+
if resp.Status == RateLimitExceededStatus {
149+
return nil, fmt.Errorf("%s", resp.Status)
150+
}
151+
144152
return resp, err
145153
}

0 commit comments

Comments
 (0)