Private
Public Access
1
0

tui: Error handling tweak

Moved errors to bottom of screen, fix infinite loop by typing errors
properly
This commit is contained in:
2024-09-23 03:37:01 +00:00
parent 172bfc57e1
commit 3ec2675632
7 changed files with 29 additions and 23 deletions

View File

@@ -91,7 +91,8 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.activeView = shared.View(msg)
return m, tea.Batch(tea.WindowSize(), shared.ViewEnter())
case shared.MsgError:
m.errs = append(m.errs, msg)
m.errs = append(m.errs, msg.Err)
return m, nil
}
view, cmd := m.views[m.activeView].Update(msg)
@@ -124,12 +125,12 @@ func (m *Model) View() string {
if content != "" {
sections = append(sections, content)
}
if len(errBanners) > 0 {
sections = append(sections, lipgloss.JoinVertical(lipgloss.Left, errBanners...))
}
if footer != "" {
sections = append(sections, footer)
}
for _, errBanner := range errBanners {
sections = append(sections, errBanner)
}
return lipgloss.JoinVertical(lipgloss.Left, sections...)
}