mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Capture API exceptions from todoist API
Rather than silently swallow, capture them and use them in rendering
This commit is contained in:
parent
c3a54de181
commit
0f9e07259e
@ -14,6 +14,10 @@ func (widget *Widget) content() (string, string, bool) {
|
|||||||
return widget.CommonSettings().Title, "", false
|
return widget.CommonSettings().Title, "", false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if proj.err != nil {
|
||||||
|
return widget.CommonSettings().Title, proj.err.Error(), true
|
||||||
|
}
|
||||||
|
|
||||||
title := fmt.Sprintf("[green]%s[white]", proj.Project.Name)
|
title := fmt.Sprintf("[green]%s[white]", proj.Project.Name)
|
||||||
|
|
||||||
str := ""
|
str := ""
|
||||||
|
@ -11,21 +11,22 @@ type Project struct {
|
|||||||
|
|
||||||
index int
|
index int
|
||||||
tasks []todoist.Task
|
tasks []todoist.Task
|
||||||
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewProject(id int) *Project {
|
func NewProject(id int) *Project {
|
||||||
// Todoist seems to experience a lot of network issues on their side
|
// Todoist seems to experience a lot of network issues on their side
|
||||||
// If we can't connect, handle it with an empty project until we can
|
// If we can't connect, handle it with an empty project until we can
|
||||||
project, err := todoist.GetProject(id)
|
project, err := todoist.GetProject(id)
|
||||||
if err != nil {
|
|
||||||
return &Project{}
|
|
||||||
}
|
|
||||||
|
|
||||||
proj := &Project{
|
proj := &Project{
|
||||||
Project: project,
|
|
||||||
|
|
||||||
index: -1,
|
index: -1,
|
||||||
}
|
}
|
||||||
|
if err != nil {
|
||||||
|
proj.err = err
|
||||||
|
return proj
|
||||||
|
}
|
||||||
|
|
||||||
|
proj.Project = project
|
||||||
|
|
||||||
proj.loadTasks()
|
proj.loadTasks()
|
||||||
|
|
||||||
@ -38,7 +39,11 @@ func (proj *Project) isLast() bool {
|
|||||||
|
|
||||||
func (proj *Project) loadTasks() {
|
func (proj *Project) loadTasks() {
|
||||||
tasks, err := todoist.ListTask(todoist.QueryParam{"project_id": fmt.Sprintf("%d", proj.ID)})
|
tasks, err := todoist.ListTask(todoist.QueryParam{"project_id": fmt.Sprintf("%d", proj.ID)})
|
||||||
if err == nil {
|
if err != nil {
|
||||||
|
proj.err = err
|
||||||
|
proj.tasks = nil
|
||||||
|
} else {
|
||||||
|
proj.err = nil
|
||||||
proj.tasks = tasks
|
proj.tasks = tasks
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user