-
Notifications
You must be signed in to change notification settings - Fork 16
/
ui_commit_error.go
46 lines (38 loc) · 879 Bytes
/
ui_commit_error.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
)
var (
layOutStyle = lipgloss.NewStyle().
Padding(1, 0, 1, 2)
errorStyle = lipgloss.NewStyle().
Bold(true).
Width(64).
Foreground(lipgloss.AdaptiveColor{Light: "#E11C9C", Dark: "#FF62DA"}).
Border(lipgloss.RoundedBorder()).
BorderForeground(lipgloss.AdaptiveColor{Light: "#E11C9C", Dark: "#FF62DA"}).
Padding(1, 3, 1, 3)
)
type errorModel struct {
err error
}
func newErrorModel() errorModel {
return errorModel{}
}
func (m errorModel) Init() tea.Cmd {
return nil
}
func (m errorModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg.(type) {
case error:
m.err = msg.(error)
}
return m, tea.Quit
}
func (m errorModel) View() string {
if m.err == nil {
return ""
}
return layOutStyle.Render(errorStyle.Render(m.err.Error()))
}