Skip to content

Commit bea5db8

Browse files
committed
better errors
1 parent 9bef663 commit bea5db8

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

client/repos.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,11 @@ func (c *Client) GetRepoTeams(ctx context.Context, org, repo string) ([]*github.
137137
return nil, fmt.Errorf("github: hit rate limit")
138138
}
139139

140-
return nil, fmt.Errorf("get repo teams: %w", err)
141-
}
140+
if resp.StatusCode == http.StatusNotFound {
141+
return nil, ErrRepoNotFound
142+
}
142143

143-
if resp.StatusCode == http.StatusNotFound {
144-
return nil, ErrRepoNotFound
144+
return nil, fmt.Errorf("get repo teams: %w", err)
145145
}
146146

147147
return teams, nil
@@ -150,7 +150,7 @@ func (c *Client) GetRepoTeams(ctx context.Context, org, repo string) ([]*github.
150150
func (c *Client) AddRepoToTeam(ctx context.Context, org, team, repo, perm string) error {
151151
gts, err := c.GetRepoTeams(ctx, org, repo)
152152
if err != nil {
153-
return err
153+
return fmt.Errorf("add repo team: %w", err)
154154
}
155155

156156
gtps := map[string]string{}

cmd/apply_repos.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package cmd
33
import (
44
"context"
55
"errors"
6+
"fmt"
67
"io"
78
"os"
89
"strings"
@@ -301,7 +302,7 @@ func setTeamPermissions(ctx context.Context, org string, repo *gh_pb.Repository,
301302

302303
gts, err := clt.GetRepoTeams(ctx, org, repo.Name)
303304
if err != nil {
304-
return err
305+
return fmt.Errorf("remove unamaged teams: %w", err)
305306
}
306307

307308
for _, gt := range gts {

0 commit comments

Comments
 (0)