Skip to content

Commit

Permalink
if win and error - no colors
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Gorochovsky committed Jul 20, 2020
1 parent e4acb4d commit 4256169
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"errors"
"fmt"
"runtime"
"strings"

"github.com/labstack/gommon/color"
Expand Down Expand Up @@ -81,11 +82,14 @@ func wrapErr(err error, appendString string, clr color.Color) error {
if err == nil {
return err
}
fmt.Println("Error:", err.Error())

if runtime.GOOS == "windows" {
clr.Disable()
}

errs := strings.Split(err.Error(), "\n")
buff := bytes.NewBufferString("")
errPrefix := clr.Red("ERR!") + " "
fmt.Println("errPrefix:", errPrefix)
for i, e := range errs {
if i != 0 {
buff.WriteByte('\n')
Expand All @@ -94,7 +98,6 @@ func wrapErr(err error, appendString string, clr color.Color) error {
buff.WriteString(e)
}
buff.WriteString(appendString)
fmt.Println("buff.String():", buff.String())
return wrapError{err: err, msg: buff.String()}
}

Expand Down

0 comments on commit 4256169

Please sign in to comment.