diff options
| author | Jeff Carr <[email protected]> | 2025-10-13 09:53:15 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-13 09:53:15 -0500 |
| commit | d4b928f7bb8f66afc31a95fa4552b8fd8fba3712 (patch) | |
| tree | 689a40f652bd2f784eb1e028340282bdb2f5739b /exit.go | |
| parent | 915ea4f648f8639cb1fc4111fa49ff298ea79441 (diff) | |
calls back to the apps' main/argv.go but what next?
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) } |
