From 3fd44ebd38edeac033727412235fcfda2ccca142 Mon Sep 17 00:00:00 2001 From: satakshigarg Date: Thu, 17 Nov 2022 19:43:01 +0530 Subject: [PATCH] Resolved Git API Errors Signed-off-by: satakshigarg --- cmd/update.go | 2 +- common/common.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/update.go b/cmd/update.go index c11a5168..c17fc1a2 100644 --- a/cmd/update.go +++ b/cmd/update.go @@ -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) diff --git a/common/common.go b/common/common.go index f6184541..cd15f6e7 100644 --- a/common/common.go +++ b/common/common.go @@ -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) @@ -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 }