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

Refactor a number of widgets to display client errors

Rather than swallowing or crashing, display appropriate errors
This commit is contained in:
Sean Smith
2019-09-01 13:19:07 -04:00
parent ff77a3deb0
commit 8835f532cc
12 changed files with 83 additions and 60 deletions

View File

@@ -31,6 +31,11 @@ func (widget *Widget) display() {
func (widget *Widget) content() (string, string, bool) {
title := widget.settings.common.Title
calEvents := widget.calEvents
if widget.err != nil {
return title, widget.err.Error(), true
}
if (calEvents == nil) || (len(calEvents) == 0) {
return title, "No calendar events", false
}

View File

@@ -11,6 +11,7 @@ type Widget struct {
app *tview.Application
calEvents []*CalEvent
settings *Settings
err error
}
func NewWidget(app *tview.Application, settings *Settings) *Widget {
@@ -45,8 +46,10 @@ func (widget *Widget) Refresh() {
func (widget *Widget) fetchAndDisplayEvents() {
calEvents, err := widget.Fetch()
if err != nil {
widget.err = err
widget.calEvents = []*CalEvent{}
} else {
widget.err = nil
widget.calEvents = calEvents
}