Skip to content

Commit

Permalink
Resolved Git API Errors
Browse files Browse the repository at this point in the history
Signed-off-by: satakshigarg <satakshi@civo.com>
  • Loading branch information
satakshigarg committed Nov 17, 2022
1 parent 11d0338 commit 3fd44eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var (
// fetch the new releases
releases, err := m.LatestReleases()
if err != nil {
if common.IsGHRatelimitError(err) {
if common.IsGHError(err) {
options := "1. Wait a few minutes and try again\n 2. Try switching to a different network (e.g. mobile data, VPN, etc)\n 3. Download latest CLI from https://github.com/civo/cli/releases"
fmt.Println("You have reached the github rate limit:\n " + options)
os.Exit(1)
Expand Down
8 changes: 4 additions & 4 deletions common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func VersionCheck() (res *latest.CheckResponse, skip bool) {
}
res, err := latest.Check(githubTag, strings.Replace(VersionCli, "v", "", 1))
if err != nil {
if IsGHRatelimitError(err) {
if IsGHError(err) {
return nil, true
}
fmt.Printf("Checking for a newer version failed with %s \n", err)
Expand All @@ -45,8 +45,8 @@ func VersionCheck() (res *latest.CheckResponse, skip bool) {
return res, false
}

// IsGHRatelimitError checks if the error is a github rate limit error
func IsGHRatelimitError(err error) bool {
_, ok := err.(*github.RateLimitError)
// IsGHError checks if the error is a github rate limit error
func IsGHError(err error) bool {
_, ok := err.(*github.ErrorResponse)
return ok
}

0 comments on commit 3fd44eb

Please sign in to comment.