Better error view language depending on whether error is fatal

This commit is contained in:
Christian Rocha 2020-07-16 15:41:16 -04:00 committed by Christian Muehlhaeuser
commit 4cfd1fc897
2 changed files with 10 additions and 4 deletions

View file

@ -443,7 +443,7 @@ func stashUpdate(msg tea.Msg, m stashModel) (stashModel, tea.Cmd) {
func stashView(m stashModel) string {
if m.showError {
return errorView(m.err)
return errorView(m.err, false)
}
var s string

View file

@ -323,7 +323,7 @@ func view(mdl tea.Model) string {
}
if m.fatalErr != nil {
return errorView(m.fatalErr)
return errorView(m.fatalErr, true)
}
var s string
@ -338,14 +338,20 @@ func view(mdl tea.Model) string {
return "\n" + indent(s, 2)
}
func errorView(err error) string {
func errorView(err error, fatal bool) string {
exitMsg := "press any key to "
if fatal {
exitMsg += "exit"
} else {
exitMsg += "return"
}
s := fmt.Sprintf("%s\n\n%v\n\n%s",
te.String(" ERROR ").
Foreground(common.Cream.Color()).
Background(common.Red.Color()).
String(),
err,
common.Subtle("Press any key to exit"),
common.Subtle(exitMsg),
)
return "\n" + indent(s, 3)
}