Merge pull request #408 from briantkennedy/rel
Improve error message for askpass.
This commit is contained in:
commit
921bd812d6
|
|
@ -1136,11 +1136,17 @@ func callGitAskPassURL(ctx context.Context, url string) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("can't access auth URL: %w", err)
|
return fmt.Errorf("can't access auth URL: %w", err)
|
||||||
}
|
}
|
||||||
|
defer func() {
|
||||||
|
_ = resp.Body.Close()
|
||||||
|
}()
|
||||||
if resp.StatusCode != 200 {
|
if resp.StatusCode != 200 {
|
||||||
return fmt.Errorf("auth URL returned status %d", resp.StatusCode)
|
errMessage, err := ioutil.ReadAll(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("auth URL returned status %d, failed to read body: %w", resp.StatusCode, err)
|
||||||
|
}
|
||||||
|
return fmt.Errorf("auth URL returned status %d, body: %q", resp.StatusCode, string(errMessage))
|
||||||
}
|
}
|
||||||
authData, err := ioutil.ReadAll(resp.Body)
|
authData, err := ioutil.ReadAll(resp.Body)
|
||||||
resp.Body.Close()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("can't read auth response: %w", err)
|
return fmt.Errorf("can't read auth response: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue