558: handle multi formatter errors

This commit is contained in:
mh-cbon
2016-11-13 22:20:13 +01:00
parent af372e8e2a
commit b0a8f25773
2 changed files with 33 additions and 6 deletions

View File

@@ -81,10 +81,12 @@ func HandleExitCoder(err error) {
}
if exitErr, ok := err.(ExitCoder); ok {
if _, ok := exitErr.(ErrorFormatter); ok {
fmt.Fprintf(ErrWriter, "%+v\n", err)
} else {
fmt.Fprintln(ErrWriter, err)
if err.Error() != "" {
if _, ok := exitErr.(ErrorFormatter); ok {
fmt.Fprintf(ErrWriter, "%+v\n", err)
} else {
fmt.Fprintln(ErrWriter, err)
}
}
OsExiter(exitErr.ExitCode())
return
@@ -98,7 +100,11 @@ func HandleExitCoder(err error) {
}
if err.Error() != "" {
fmt.Fprintln(ErrWriter, err)
if _, ok := err.(ErrorFormatter); ok {
fmt.Fprintf(ErrWriter, "%+v\n", err)
} else {
fmt.Fprintln(ErrWriter, err)
}
}
OsExiter(1)
}