Skip to content

Commit

Permalink
refactor: include entire error msg
Browse files Browse the repository at this point in the history
  • Loading branch information
bashbunni committed Oct 19, 2024
1 parent a87cc86 commit 07ff573
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions error.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 07ff573

Please sign in to comment.