Skip to content

Commit

Permalink
Normalize url.Error message for Go 1.14
Browse files Browse the repository at this point in the history
Go 1.13: `Post <URL>: <message>`
Go 1.14: `Post "<URL>": <message>`

Since we have an existing test that includes this error message, make
sure that `url.Error`s are output without quotes around the URL.
  • Loading branch information
mislav committed Mar 5, 2020
1 parent d675a5e commit 5b7cf00
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion github/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,11 @@ func reverseNormalizeHost(host string) string {

func checkStatus(expectedStatus int, action string, response *simpleResponse, err error) error {
if err != nil {
return fmt.Errorf("Error %s: %s", action, err.Error())
errStr := err.Error()
if urlErr, isURLErr := err.(*url.Error); isURLErr {
errStr = fmt.Sprintf("%s %s: %s", urlErr.Op, urlErr.URL, urlErr.Err)
}
return fmt.Errorf("Error %s: %s", action, errStr)
} else if response.StatusCode != expectedStatus {
errInfo, err := response.ErrorInfo()
if err != nil {
Expand Down

0 comments on commit 5b7cf00

Please sign in to comment.