Add response body to error when fetching access token (#4005)
Co-authored-by: mluffman <mluffman@thoughtmachine.net> Co-authored-by: Nikola Jokic <jokicnikola07@gmail.com>
This commit is contained in:
parent
c359d14e69
commit
e335f53037
|
|
@ -1060,10 +1060,15 @@ func (c *Client) fetchAccessToken(ctx context.Context, gitHubConfigURL string, c
|
|||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusCreated {
|
||||
errMsg := fmt.Sprintf("failed to get access token for GitHub App auth (%v)", resp.Status)
|
||||
if body, err := io.ReadAll(resp.Body); err == nil {
|
||||
errMsg = fmt.Sprintf("%s: %s", errMsg, string(body))
|
||||
}
|
||||
|
||||
return nil, &GitHubAPIError{
|
||||
StatusCode: resp.StatusCode,
|
||||
RequestID: resp.Header.Get(HeaderGitHubRequestID),
|
||||
Err: fmt.Errorf("failed to get access token for GitHub App auth: %v", resp.Status),
|
||||
Err: errors.New(errMsg),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue