mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
WTF-389 Log an exception and terminate if widget config is invalid
If, on startup, a widget's positional configuration is invalid (ie: cannot be displayed onscreen) then terminate the app and inform about which widget is erroring
This commit is contained in:
@@ -40,7 +40,7 @@ func (widget *Widget) Refresh() {
|
||||
wtf.Now().Format(wtf.DateFormat),
|
||||
)
|
||||
|
||||
widget.View.SetTitle(widget.ContextualTitle(widget.Name))
|
||||
widget.View.SetTitle(widget.ContextualTitle(widget.Name()))
|
||||
|
||||
widget.View.SetText(widget.contentFrom(todayItems))
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ func (widget *Widget) Refresh() {
|
||||
|
||||
builds, err := widget.Client.BuildsFor()
|
||||
|
||||
widget.View.SetTitle(fmt.Sprintf("%s - Builds", widget.Name))
|
||||
widget.View.SetTitle(fmt.Sprintf("%s - Builds", widget.Name()))
|
||||
|
||||
var content string
|
||||
if err != nil {
|
||||
|
||||
@@ -25,7 +25,7 @@ func NewWidget(app *tview.Application) *Widget {
|
||||
func (widget *Widget) Refresh() {
|
||||
monitors, monitorErr := Monitors()
|
||||
|
||||
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s", widget.Name)))
|
||||
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s", widget.Name())))
|
||||
widget.View.Clear()
|
||||
|
||||
var content string
|
||||
|
||||
@@ -32,7 +32,7 @@ func (widget *Widget) display() {
|
||||
widget.mutex.Lock()
|
||||
defer widget.mutex.Unlock()
|
||||
|
||||
widget.View.SetTitle(widget.ContextualTitle(widget.Name))
|
||||
widget.View.SetTitle(widget.ContextualTitle(widget.Name()))
|
||||
widget.View.SetText(widget.contentFrom(widget.calEvents))
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ func (widget *Widget) display() {
|
||||
return
|
||||
}
|
||||
|
||||
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s- %s", widget.Name, widget.title(project))))
|
||||
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s- %s", widget.Name(), widget.title(project))))
|
||||
|
||||
str := wtf.SigilStr(len(widget.GerritProjects), widget.Idx, widget.View) + "\n"
|
||||
str = str + " [red]Stats[white]\n"
|
||||
|
||||
@@ -94,7 +94,7 @@ func (widget *Widget) Refresh() {
|
||||
gerrit, err := glb.NewClient(gerritUrl, httpClient)
|
||||
if err != nil {
|
||||
widget.View.SetWrap(true)
|
||||
widget.View.SetTitle(widget.Name)
|
||||
widget.View.SetTitle(widget.Name())
|
||||
widget.View.SetText(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ func (widget *Widget) display() {
|
||||
return
|
||||
}
|
||||
|
||||
title := fmt.Sprintf("%s - [green]%s[white]", widget.Name, repoData.Repository)
|
||||
title := fmt.Sprintf("%s - [green]%s[white]", widget.Name(), repoData.Repository)
|
||||
widget.View.SetTitle(widget.ContextualTitle(title))
|
||||
|
||||
str := wtf.SigilStr(len(widget.GitRepos), widget.Idx, widget.View) + "\n"
|
||||
|
||||
@@ -14,7 +14,7 @@ func (widget *Widget) display() {
|
||||
return
|
||||
}
|
||||
|
||||
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s - %s", widget.Name, widget.title(repo))))
|
||||
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s - %s", widget.Name(), widget.title(repo))))
|
||||
|
||||
str := wtf.SigilStr(len(widget.GithubRepos), widget.Idx, widget.View) + "\n"
|
||||
str = str + " [red]Stats[white]\n"
|
||||
|
||||
@@ -14,7 +14,7 @@ func (widget *Widget) display() {
|
||||
return
|
||||
}
|
||||
|
||||
widget.View.SetTitle(fmt.Sprintf("%s- %s", widget.Name, widget.title(project)))
|
||||
widget.View.SetTitle(fmt.Sprintf("%s- %s", widget.Name(), widget.title(project)))
|
||||
|
||||
str := wtf.SigilStr(len(widget.GitlabProjects), widget.Idx, widget.View) + "\n"
|
||||
str = str + " [red]Stats[white]\n"
|
||||
|
||||
@@ -54,7 +54,7 @@ func (widget *Widget) Refresh() {
|
||||
room, err := GetRoom(wtf.Config.UString("wtf.mods.gitter.roomUri", "wtfutil/Lobby"))
|
||||
if err != nil {
|
||||
widget.View.SetWrap(true)
|
||||
widget.View.SetTitle(widget.Name)
|
||||
widget.View.SetTitle(widget.Name())
|
||||
widget.View.SetText(err.Error())
|
||||
return
|
||||
}
|
||||
@@ -67,7 +67,7 @@ func (widget *Widget) Refresh() {
|
||||
|
||||
if err != nil {
|
||||
widget.View.SetWrap(true)
|
||||
widget.View.SetTitle(widget.Name)
|
||||
widget.View.SetTitle(widget.Name())
|
||||
widget.View.SetText(err.Error())
|
||||
} else {
|
||||
widget.messages = messages
|
||||
@@ -86,7 +86,7 @@ func (widget *Widget) display() {
|
||||
|
||||
widget.View.SetWrap(true)
|
||||
widget.View.Clear()
|
||||
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s - %s", widget.Name, wtf.Config.UString("wtf.mods.gitter.roomUri", "wtfutil/Lobby"))))
|
||||
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s - %s", widget.Name(), wtf.Config.UString("wtf.mods.gitter.roomUri", "wtfutil/Lobby"))))
|
||||
widget.View.SetText(widget.contentFrom(widget.messages))
|
||||
widget.View.Highlight(strconv.Itoa(widget.selected)).ScrollToHighlight()
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ func (widget *Widget) Refresh() {
|
||||
|
||||
if err != nil {
|
||||
widget.View.SetWrap(true)
|
||||
widget.View.SetTitle(widget.Name)
|
||||
widget.View.SetTitle(widget.Name())
|
||||
widget.View.SetText(err.Error())
|
||||
} else {
|
||||
var stories []Story
|
||||
@@ -94,7 +94,7 @@ func (widget *Widget) display() {
|
||||
widget.View.SetWrap(false)
|
||||
|
||||
widget.View.Clear()
|
||||
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s - %sstories", widget.Name, wtf.Config.UString("wtf.mods.hackernews.storyType", "top"))))
|
||||
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s - %sstories", widget.Name(), wtf.Config.UString("wtf.mods.hackernews.storyType", "top"))))
|
||||
widget.View.SetText(widget.contentFrom(widget.stories))
|
||||
widget.View.Highlight(strconv.Itoa(widget.selected)).ScrollToHighlight()
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ func (widget *Widget) Refresh() {
|
||||
|
||||
if err != nil {
|
||||
widget.View.SetWrap(true)
|
||||
widget.View.SetTitle(widget.ContextualTitle(widget.Name))
|
||||
widget.View.SetTitle(widget.ContextualTitle(widget.Name()))
|
||||
widget.View.SetText(err.Error())
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ func (widget *Widget) display() {
|
||||
widget.View.SetWrap(false)
|
||||
|
||||
widget.View.Clear()
|
||||
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s: [red]%s", widget.Name, widget.view.Name)))
|
||||
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s: [red]%s", widget.Name(), widget.view.Name)))
|
||||
widget.View.SetText(widget.contentFrom(widget.view))
|
||||
widget.View.Highlight(strconv.Itoa(widget.selected)).ScrollToHighlight()
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ func (widget *Widget) Refresh() {
|
||||
if err != nil {
|
||||
widget.result = nil
|
||||
widget.View.SetWrap(true)
|
||||
widget.View.SetTitle(widget.Name)
|
||||
widget.View.SetTitle(widget.Name())
|
||||
widget.View.SetText(err.Error())
|
||||
} else {
|
||||
widget.result = searchResult
|
||||
@@ -74,7 +74,7 @@ func (widget *Widget) display() {
|
||||
}
|
||||
widget.View.SetWrap(false)
|
||||
|
||||
str := fmt.Sprintf("%s- [green]%s[white]", widget.Name, wtf.Config.UString("wtf.mods.jira.project"))
|
||||
str := fmt.Sprintf("%s- [green]%s[white]", widget.Name(), wtf.Config.UString("wtf.mods.jira.project"))
|
||||
|
||||
widget.View.Clear()
|
||||
widget.View.SetTitle(widget.ContextualTitle(str))
|
||||
|
||||
@@ -15,7 +15,7 @@ func (widget *Widget) display() {
|
||||
return
|
||||
}
|
||||
|
||||
title := fmt.Sprintf("%s - [green]%s[white]", widget.Name, repoData.Repository)
|
||||
title := fmt.Sprintf("%s - [green]%s[white]", widget.Name(), repoData.Repository)
|
||||
widget.View.SetTitle(widget.ContextualTitle(title))
|
||||
|
||||
str := wtf.SigilStr(len(widget.Data), widget.Idx, widget.View) + "\n"
|
||||
|
||||
@@ -47,7 +47,7 @@ func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
||||
func (widget *Widget) Refresh() {
|
||||
widget.nbascore()
|
||||
|
||||
widget.View.SetTitle(widget.ContextualTitle(widget.Name))
|
||||
widget.View.SetTitle(widget.ContextualTitle(widget.Name()))
|
||||
}
|
||||
|
||||
func (widget *Widget) nbascore() {
|
||||
|
||||
@@ -34,7 +34,7 @@ func (widget *Widget) Refresh() {
|
||||
appName = app.Name
|
||||
}
|
||||
|
||||
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s - [green]%s[white]", widget.Name, appName)))
|
||||
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s - [green]%s[white]", widget.Name(), appName)))
|
||||
widget.View.Clear()
|
||||
|
||||
var content string
|
||||
|
||||
@@ -27,7 +27,7 @@ func (widget *Widget) Refresh() {
|
||||
wtf.Config.UString("wtf.mods.opsgenie.scheduleIdentifierType"),
|
||||
getSchedules(),
|
||||
)
|
||||
widget.View.SetTitle(widget.ContextualTitle(widget.Name))
|
||||
widget.View.SetTitle(widget.ContextualTitle(widget.Name()))
|
||||
|
||||
var content string
|
||||
if err != nil {
|
||||
|
||||
@@ -38,7 +38,7 @@ func (widget *Widget) Refresh() {
|
||||
incidents, err2 = GetIncidents()
|
||||
}
|
||||
|
||||
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s", widget.Name)))
|
||||
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s", widget.Name())))
|
||||
widget.View.Clear()
|
||||
|
||||
var content string
|
||||
|
||||
@@ -55,7 +55,7 @@ func (widget *Widget) Refresh() {
|
||||
|
||||
if err != nil {
|
||||
widget.View.SetWrap(true)
|
||||
widget.View.SetTitle(widget.Name)
|
||||
widget.View.SetTitle(widget.Name())
|
||||
widget.View.SetText(err.Error())
|
||||
} else {
|
||||
widget.items = &items.Results
|
||||
@@ -73,7 +73,7 @@ func (widget *Widget) display() {
|
||||
|
||||
widget.View.SetWrap(false)
|
||||
projectName := wtf.Config.UString("wtf.mods.rollbar.projectName", "Items")
|
||||
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s - %s", widget.Name, projectName)))
|
||||
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s - %s", widget.Name(), projectName)))
|
||||
widget.View.SetText(widget.contentFrom(widget.items))
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ func (widget *Widget) Refresh() {
|
||||
widget.load()
|
||||
widget.display()
|
||||
|
||||
widget.View.SetTitle(widget.ContextualTitle(widget.Name))
|
||||
widget.View.SetTitle(widget.ContextualTitle(widget.Name()))
|
||||
}
|
||||
|
||||
func (widget *Widget) SetList(newList checklist.Checklist) {
|
||||
|
||||
@@ -55,7 +55,7 @@ func (widget *Widget) Refresh() {
|
||||
|
||||
if err != nil {
|
||||
widget.View.SetWrap(true)
|
||||
widget.View.SetTitle(widget.Name)
|
||||
widget.View.SetTitle(widget.Name())
|
||||
widget.View.SetText(err.Error())
|
||||
} else {
|
||||
widget.builds = builds
|
||||
@@ -73,7 +73,7 @@ func (widget *Widget) display() {
|
||||
|
||||
widget.View.SetWrap(false)
|
||||
|
||||
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s - Builds", widget.Name)))
|
||||
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s - Builds", widget.Name())))
|
||||
widget.View.SetText(widget.contentFrom(widget.builds))
|
||||
}
|
||||
|
||||
|
||||
@@ -35,14 +35,14 @@ func (widget *Widget) Refresh() {
|
||||
var content string
|
||||
if err != nil {
|
||||
widget.View.SetWrap(true)
|
||||
widget.View.SetTitle(widget.Name)
|
||||
widget.View.SetTitle(widget.Name())
|
||||
content = err.Error()
|
||||
} else {
|
||||
widget.View.SetWrap(false)
|
||||
widget.View.SetTitle(
|
||||
fmt.Sprintf(
|
||||
"[white]%s: [green]%s ",
|
||||
widget.Name,
|
||||
widget.Name(),
|
||||
wtf.Config.UString("wtf.mods.trello.board"),
|
||||
),
|
||||
)
|
||||
|
||||
@@ -23,9 +23,9 @@ func NewWidget(app *tview.Application, name string) *Widget {
|
||||
|
||||
func (widget *Widget) Refresh() {
|
||||
|
||||
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s", widget.Name)))
|
||||
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s", widget.Name())))
|
||||
widget.View.Clear()
|
||||
|
||||
content := fmt.Sprintf("Widget %s does not exist", widget.Name)
|
||||
content := fmt.Sprintf("Widget %s does not exist", widget.Name())
|
||||
widget.View.SetText(content)
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ func (widget *Widget) Refresh() {
|
||||
}
|
||||
|
||||
teams, err := Fetch()
|
||||
widget.View.SetTitle(widget.ContextualTitle(widget.Name))
|
||||
widget.View.SetTitle(widget.ContextualTitle(widget.Name()))
|
||||
|
||||
if err != nil {
|
||||
widget.View.SetWrap(true)
|
||||
|
||||
@@ -43,7 +43,7 @@ func (widget *Widget) Refresh() {
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
||||
func (widget *Widget) display() {
|
||||
widget.View.SetTitle(fmt.Sprintf("%s (%d)", widget.Name, widget.result.Count))
|
||||
widget.View.SetTitle(fmt.Sprintf("%s (%d)", widget.Name(), widget.result.Count))
|
||||
widget.View.SetText(widget.textContent(widget.result.Tickets))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user