Skip to content

Commit

Permalink
Add clarification around error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Bob Aman committed Jan 15, 2019
1 parent 0abdd67 commit e67f1a6
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/auth/providers/ms_graph_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ func (gs *MSGraphService) GetGroups(email string) ([]string, error) {
if cachedName, ok := gs.groupNameCache.Get(id); !ok {
// didn't have the group name, make concurrent API call to fetch it
name, err = gs.getGroupName(id)
// the err value is not shadowed in the goroutine, so if this isn't
// nil, it will return the err value after wg.Wait() is called
if err == nil {
// got the name ok, populate the cache
gs.groupNameCache.Add(id, name)
Expand All @@ -136,6 +138,7 @@ func (gs *MSGraphService) GetGroups(email string) ([]string, error) {
}
}
wg.Wait()
// any err value set above will cause this to fail
if err != nil {
return nil, err
}
Expand Down

0 comments on commit e67f1a6

Please sign in to comment.