Skip to content
This repository was archived by the owner on Feb 27, 2018. It is now read-only.

Commit 85fc73f

Browse files
Sven DowideitSven Dowideit
authored andcommitted
Merge pull request #220 from SvenDowideit/show-github-error-details
Expand the github error message - and show the JSON payload if even that...
2 parents 3cbe794 + c29f518 commit 85fc73f

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

util.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"encoding/json"
88
"fmt"
99
"io"
10+
"io/ioutil"
1011
"log"
1112
"net"
1213
"net/http"
@@ -106,9 +107,21 @@ func getLatestReleaseName(url string) (string, error) {
106107
var t []struct {
107108
TagName string `json:"tag_name"`
108109
}
109-
if err := json.NewDecoder(rsp.Body).Decode(&t); err != nil {
110+
body, err := ioutil.ReadAll(rsp.Body)
111+
if err != nil {
110112
return "", err
111113
}
114+
115+
if err := json.Unmarshal(body, &t); err != nil {
116+
var e struct {
117+
Message string
118+
DocumentationUrl string
119+
}
120+
if err := json.Unmarshal(body, &e); err != nil {
121+
return "", fmt.Errorf("Error decoding %s\nbody: %s", err, body)
122+
}
123+
return "", fmt.Errorf("Error getting releases: %s\n see %s", e.Message, e.DocumentationUrl)
124+
}
112125
if len(t) == 0 {
113126
return "", fmt.Errorf("no releases found")
114127
}

0 commit comments

Comments
 (0)