Skip to content

feat: improve CLI error messages #6778

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Mar 28, 2023
Prev Previous commit
Next Next commit
Cleanup styling
  • Loading branch information
ammario committed Mar 24, 2023
commit f8d5ecb6c2aed71650d486f11e2290cfe3b9cf57
20 changes: 10 additions & 10 deletions cli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -854,25 +854,25 @@ func (p *prettyErrorFormatter) format(err error) {
msg = headErr
}

textStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("#D16644"))
if errTail != nil {
msg = msg + ": "
}
headStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("#D16644"))
p.printf(
headStyle,
"%s",
textStyle.Render(msg),
msg,
)

tailStyle := headStyle.Copy().Foreground(lipgloss.Color("#969696"))

if errTail != nil {
p.printf(headStyle, ": ")
// Grey out the less important, deep errors.
textStyle.Foreground(lipgloss.Color("#969696"))
p.printf("%s", textStyle.Render(errTail.Error()))
p.printf(tailStyle, "%s", errTail.Error())
}
p.printf("\n")
p.printf(tailStyle, "\n")
}

func (p *prettyErrorFormatter) printf(format string, a ...interface{}) {
s := fmt.Sprintf(format, a...)
func (p *prettyErrorFormatter) printf(style lipgloss.Style, format string, a ...interface{}) {
s := style.Render(fmt.Sprintf(format, a...))
_, _ = p.w.Write(
[]byte(
s,
Expand Down