mirror of
https://github.com/charmbracelet/glow.git
synced 2026-08-22 08:04:18 +02:00
Better error view language depending on whether error is fatal
This commit is contained in:
parent
3409ca342a
commit
4cfd1fc897
2 changed files with 10 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
12
ui/ui.go
12
ui/ui.go
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue