Send all ExitError output through PrintMark

main v0.19.0
Rob Muhlestein 2 years ago
parent 95028d5d8f
commit 163c728cea

@ -245,22 +245,34 @@ func Exit() {
// has been set to true. Commands should usually never call ExitError // has been set to true. Commands should usually never call ExitError
// themselves returning an error from their Method instead. // themselves returning an error from their Method instead.
func ExitError(err ...interface{}) { func ExitError(err ...interface{}) {
prev := os.Stdout
os.Stdout = os.Stderr
previ := IndentBy
IndentBy = 0
switch e := err[0].(type) { switch e := err[0].(type) {
case string: case string:
if len(e) > 1 { if len(e) > 1 {
log.Printf(e+"\n", err[1:]...) PrintMarkf(e+"\n", err[1:]...)
} else { } else {
log.Println(e) PrintMark(e)
} }
case error: case error:
out := fmt.Sprintf("%v", e) out := fmt.Sprintf("%v", e)
if len(out) > 0 { if len(out) > 0 {
log.Println(out) PrintMark(out)
} }
} }
IndentBy = previ
os.Stdout = prev
if !DoNotExit { if !DoNotExit {
os.Exit(1) os.Exit(1)
} }
} }
// ArgsFrom returns a list of field strings split on space with an extra // ArgsFrom returns a list of field strings split on space with an extra

Loading…
Cancel
Save