add response body to error if possible
This commit is contained in:
parent
4ca37fbdf2
commit
d4c7d7f2fc
|
|
@ -1056,11 +1056,17 @@ func (c *Client) fetchAccessToken(ctx context.Context, gitHubConfigURL string, c
|
|||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusCreated {
|
||||
return nil, &GitHubAPIError{
|
||||
rErr := &GitHubAPIError{
|
||||
StatusCode: resp.StatusCode,
|
||||
RequestID: resp.Header.Get(HeaderGitHubRequestID),
|
||||
Err: fmt.Errorf("failed to get access token for GitHub App auth: %v", resp.Status),
|
||||
}
|
||||
msg, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, rErr
|
||||
}
|
||||
rErr.Err = fmt.Errorf("%w: %s", rErr.Err, msg)
|
||||
return nil, rErr
|
||||
}
|
||||
|
||||
// Format: https://docs.github.com/en/rest/apps/apps#create-an-installation-access-token-for-an-app
|
||||
|
|
|
|||
Loading…
Reference in New Issue