diff options
Diffstat (limited to 'exit.go')
| -rw-r--r-- | exit.go | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -30,11 +30,22 @@ func (pb *Auto) BadExit(msg string, err error) { if myAuto.appExit != nil { myAuto.appExit() } + // print out errors. this handles wrapped errors which is a useful if err != nil { - log.Info(err) + if u, ok := err.(interface{ Unwrap() []error }); ok { + // If it does, call the method to get the slice of errors. + allerr := u.Unwrap() + for _, e := range allerr { + log.Info("Error:", e) + } + } else { + // If it's not a joined error, you can fall back to the single-unwrap loop. + log.Info("Error:", err) + } } + dur := time.Since(pb.Ctime.AsTime()) - log.Infof("%s: %s (%s)\n", pb.Argname, msg, cobol.FormatDuration(dur)) + log.Infof("%s error: %s (%s)\n", pb.Argname, msg, cobol.FormatDuration(dur)) os.Exit(-1) } |
