Skip to content

Commit

Permalink
Return an error if resp and err are nil (#617)
Browse files Browse the repository at this point in the history
This will allow retry logic to kick in and also avoid up-stream panics
due to both the response and the error being nil.
  • Loading branch information
jhendrixMSFT authored Feb 10, 2021
1 parent 8c0b29a commit 79a63e7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion autorest/adal/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -1030,9 +1030,11 @@ func (spt *ServicePrincipalToken) refreshInternal(ctx context.Context, resource
resp, err = spt.sender.Do(req)
}

// don't return a TokenRefreshError here; this will allow retry logic to apply
if err != nil {
// don't return a TokenRefreshError here; this will allow retry logic to apply
return fmt.Errorf("adal: Failed to execute the refresh request. Error = '%v'", err)
} else if resp == nil {
return fmt.Errorf("adal: received nil response and error")
}

logger.Instance.WriteResponse(resp, logger.Filter{Body: authBodyFilter})
Expand Down

0 comments on commit 79a63e7

Please sign in to comment.