1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Merge pull request #603 from Seanstoppable/handlegithubclienterr

Pass through github client errors to display
This commit is contained in:
Chris Cummer 2019-09-04 21:59:54 -07:00 committed by GitHub
commit a781c20088
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View File

@ -15,6 +15,8 @@ func (widget *Widget) content() (string, string, bool) {
title := fmt.Sprintf("%s - %s", widget.CommonSettings().Title, widget.title(repo))
if repo == nil {
return title, " GitHub repo data is unavailable ", false
} else if repo.Err != nil {
return title, repo.Err.Error(), true
}
_, _, width, _ := widget.View.GetRect()

View File

@ -19,6 +19,7 @@ type GithubRepo struct {
Owner string
PullRequests []*ghb.PullRequest
RemoteRepo *ghb.Repository
Err error
}
func NewGithubRepo(name, owner, apiKey, baseURL, uploadURL string) *GithubRepo {
@ -40,8 +41,15 @@ func (repo *GithubRepo) Open() {
// Refresh reloads the github data via the Github API
func (repo *GithubRepo) Refresh() {
repo.PullRequests, _ = repo.loadPullRequests()
repo.RemoteRepo, _ = repo.loadRemoteRepository()
prs, err := repo.loadPullRequests()
repo.Err = err
repo.PullRequests = prs
if err != nil {
return
}
remote, err := repo.loadRemoteRepository()
repo.Err = err
repo.RemoteRepo = remote
}
/* -------------------- Counts -------------------- */