Skip to content

Commit

Permalink
print more info in github requests errors
Browse files Browse the repository at this point in the history
  • Loading branch information
bakito committed Oct 21, 2024
1 parent 338ce3c commit b2e4c2f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions .toolbox.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ tools:
github: hashicorp/terraform
downloadURL: https://releases.hashicorp.com/terraform/{{ .VersionNum }}/terraform_{{ .VersionNum }}_{{ .OS }}_{{ .Arch }}.zip
check: --version
version: v1.8.5
toolbox:
github: bakito/toolbox
check: --version
Expand Down
1 change: 1 addition & 0 deletions pkg/fetcher/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ func (f *fetcher) Fetch(cfgFile string, selectedTools ...string) error {
defer func() { _ = os.RemoveAll(tmp) }()

tools := tb.GetTools()
println()
for _, tool := range tools {
if contains(selectedTools, tool.Name) {
if err := f.handleTool(client, ver, tmp, tb, tool); err != nil {
Expand Down
8 changes: 5 additions & 3 deletions pkg/github/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ func LatestRelease(client *resty.Client, repo string, quiet bool) (*types.Github
SetError(ghErr).
SetHeader("Accept", "application/json")
handleGithubToken(ghc, quiet)
resp, err := ghc.Get(latestReleaseURL(repo))
url := latestReleaseURL(repo)
resp, err := ghc.Get(url)
if err != nil {
return nil, http.CheckError(err)
}
if resp.IsError() {
return nil, fmt.Errorf("github request was not successful: %s", ghErr.Message)
return nil, fmt.Errorf("github request was not successful: %s (%d) %s", url, resp.StatusCode(), ghErr.Message)
}

if ghr.TagName == "" {
Expand Down Expand Up @@ -76,12 +77,13 @@ func Release(client *resty.Client, repo string, version string, quiet bool) (*ty

handleGithubToken(ghc, quiet)

url := releaseURL(repo, version)
resp, err := ghc.Get(releaseURL(repo, version))
if err != nil {
return nil, http.CheckError(err)
}
if resp.IsError() {
return nil, fmt.Errorf("github request was not successful: %s", ghErr.Message)
return nil, fmt.Errorf("github request was not successful: %s (%d) %s", url, resp.StatusCode(), ghErr.Message)
}

if ghr.TagName == "" {
Expand Down

0 comments on commit b2e4c2f

Please sign in to comment.