diff --git a/error.go b/error.go index a0d947d..611bd65 100644 --- a/error.go +++ b/error.go @@ -3,20 +3,27 @@ package main import ( "fmt" "os" - "strings" "github.com/charmbracelet/lipgloss" ) -var errorHeader = lipgloss.NewStyle().Foreground(lipgloss.Color("#F1F1F1")).Background(lipgloss.Color("#FF5F87")).Bold(true).Padding(0, 1).Margin(1).MarginLeft(2).SetString("ERROR") -var errorDetails = lipgloss.NewStyle().Foreground(lipgloss.Color("#757575")).MarginLeft(2) +var ( + errorHeader = lipgloss.NewStyle(). + Foreground(lipgloss.Color("#F1F1F1")). + Background(lipgloss.Color("#FF5F87")). + Bold(true). + Padding(0, 1). + Margin(1). + MarginLeft(2). + SetString("ERROR") + errorDetails = lipgloss.NewStyle(). + Foreground(lipgloss.Color("#757575")). + MarginLeft(2) +) func printError(title string, err error) { - fmt.Printf("%s\n", lipgloss.JoinHorizontal(lipgloss.Center, errorHeader.String(), title)) - splittedError := strings.Split(err.Error(), "\n") - for _, line := range splittedError { - fmt.Println(errorDetails.Render(line)) - } + fmt.Println(lipgloss.JoinHorizontal(lipgloss.Center, errorHeader.String(), title)) + fmt.Println(errorDetails.Render(err.Error())) } func printErrorFatal(title string, err error) {