Skip to content

Commit c86ed15

Browse files
authored
Merge pull request #9 from mom0tomo/fix_error_handling
Fix missing err processing and missing body closing
2 parents 2212d4c + f058c60 commit c86ed15

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

Diff for: metrics/get_billable_from_github.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ func GetBillableFromGithub() {
5151
req, _ := http.NewRequest("GET", "https://"+config.Github.ApiUrl+"/repos/"+repo+"/actions/workflows/"+strconv.Itoa(k)+"/timing", nil)
5252
req.Header.Set("Authorization", "token "+config.Github.Token)
5353
resp, err := client.Do(req)
54-
defer resp.Body.Close()
5554
if err != nil {
5655
log.Fatal(err)
5756
}
57+
defer resp.Body.Close()
5858
if resp.StatusCode != 200 {
5959
log.Fatalf("the status code returned by the server for workflows in repo %s is different from 200: %d", repo, resp.StatusCode)
6060
}

Diff for: metrics/get_runners_from_github.go

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ func GetRunnersFromGithub() {
4747
if err != nil {
4848
log.Fatal(err)
4949
}
50+
defer resp.Body.Close()
5051
if resp.StatusCode != 200 {
5152
log.Fatalf("the status code returned by the server for runners in repo %s is different from 200: %d", repo, resp.StatusCode)
5253
}

Diff for: metrics/worflows_cache.go

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ func WorkflowsCache() {
3636
if err != nil {
3737
log.Fatal(err)
3838
}
39+
3940
if resp.StatusCode != 200 {
4041
log.Fatalf("the status code returned by the server for workflows in repo %s is different from 200: %d", repo, resp.StatusCode)
4142
}

0 commit comments

Comments
 (0)