Skip to content

Commit

Permalink
Add StatusCode checks
Browse files Browse the repository at this point in the history
Signed-off-by: Saswata Mukherjee <saswataminsta@yahoo.com>
  • Loading branch information
saswatamcode committed May 22, 2021
1 parent 2a7a529 commit 2cfb2e9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/mdformatter/linktransformer/link.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ func getGitHubRegex(reponame string) (*regexp.Regexp, int, error) {
if err != nil {
return nil, math.MaxInt64, err
}
if respPull.StatusCode != 200 {
return nil, math.MaxInt64, errors.New("pulls API request failed. status code: " + strconv.Itoa(respPull.StatusCode))
}
defer respPull.Body.Close()
if err := json.NewDecoder(respPull.Body).Decode(&pullNum); err != nil {
return nil, math.MaxInt64, err
Expand All @@ -213,6 +216,9 @@ func getGitHubRegex(reponame string) (*regexp.Regexp, int, error) {
if err != nil {
return nil, math.MaxInt64, err
}
if respIssue.StatusCode != 200 {
return nil, math.MaxInt64, errors.New("issues API request failed. status code: " + strconv.Itoa(respIssue.StatusCode))
}
defer respIssue.Body.Close()
if err := json.NewDecoder(respIssue.Body).Decode(&issueNum); err != nil {
return nil, math.MaxInt64, err
Expand Down

0 comments on commit 2cfb2e9

Please sign in to comment.