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:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user