-
Notifications
You must be signed in to change notification settings - Fork 419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve error message for askpass. #407
Conversation
Welcome @briantkennedy! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can I get an equivalent PR against the master (v4 dev) branch?
cmd/git-sync/main.go
Outdated
if resp.StatusCode != 200 { | ||
return fmt.Errorf("auth URL returned status %d", resp.StatusCode) | ||
errMessage, err2 := ioutil.ReadAll(resp.Body) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can shadow err
here - it's OK, unless some linter is complaining?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
cmd/git-sync/main.go
Outdated
if err2 != nil { | ||
return fmt.Errorf("auth URL returned status %d, failed to read body: %w", resp.StatusCode, err2) | ||
} | ||
return fmt.Errorf("auth URL returned status %d body %s", resp.StatusCode, string(errMessage)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: "%d, body: %s" or even %q ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a v4 branch, do you mean the release-3.x branch?
cmd/git-sync/main.go
Outdated
if err2 != nil { | ||
return fmt.Errorf("auth URL returned status %d, failed to read body: %w", resp.StatusCode, err2) | ||
} | ||
return fmt.Errorf("auth URL returned status %d body %s", resp.StatusCode, string(errMessage)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated.
When endpoint returns non-200 status, include the body in the error message since it can contain useful information for debugging. Also defer closing the response body ReadCloser as this may have leaked in the past.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: briantkennedy, thockin The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
When endpoint returns non-200 status, include the body in the error
message since it can contain useful information for debugging. Also
defer closing the response body ReadCloser as this may have leaked in
the past.