aboutsummaryrefslogtreecommitdiffstats
path: root/internal/output
diff options
context:
space:
mode:
authorEugene Triguba <eugenetriguba@gmail.com>2024-01-28 17:47:31 -0500
committerEugene Triguba <eugenetriguba@gmail.com>2024-01-28 17:47:31 -0500
commit95eea2a07198576e3f4b0a246dd5e2b0cd4ef219 (patch)
tree7b63135924558a706322d441ae78b59d4bbd2d71 /internal/output
parentAdd test for invalid version style in config (diff)
downloadcli-95eea2a07198576e3f4b0a246dd5e2b0cd4ef219.zip
Wrap db repo and console errs to give better errors
Diffstat (limited to 'internal/output')
-rw-r--r--internal/output/console.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/internal/output/console.go b/internal/output/console.go
index d2946ed..50534dd 100644
--- a/internal/output/console.go
+++ b/internal/output/console.go
@@ -18,12 +18,12 @@ func NewConsoleOutputter() ConsoleOutputter {
func (c ConsoleOutputter) Output(message string) error {
_, err := fmt.Fprintln(c.stdout, message)
- return err
+ return fmt.Errorf("unable to print message %s: %w", message, err)
}
func (c ConsoleOutputter) Error(message string) error {
_, err := fmt.Fprintln(c.stderr, message)
- return err
+ return fmt.Errorf("unable to print message %s: %w", message, err)
}
func (c ConsoleOutputter) Table(headers []string, rows [][]string) error {
@@ -32,13 +32,13 @@ func (c ConsoleOutputter) Table(headers []string, rows [][]string) error {
for _, header := range headers {
_, err := fmt.Fprintf(w, "%s\t", header)
if err != nil {
- return err
+ return fmt.Errorf("unable to print table header %s: %w", header, err)
}
}
if len(headers) > 0 {
_, err := fmt.Fprint(w, "\n")
if err != nil {
- return err
+ return fmt.Errorf("unable to print newline after table header: %w", err)
}
}
@@ -46,12 +46,12 @@ func (c ConsoleOutputter) Table(headers []string, rows [][]string) error {
for _, cell := range row {
_, err := fmt.Fprintf(w, "%s\t", cell)
if err != nil {
- return err
+ return fmt.Errorf("unable to print table cell %s: %w", cell, err)
}
}
_, err := fmt.Fprint(w, "\n")
if err != nil {
- return err
+ return fmt.Errorf("unable to print newline for table row %s: %w", row, err)
}
}