summaryrefslogtreecommitdiff
path: root/exit.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-13 09:53:15 -0500
committerJeff Carr <[email protected]>2025-10-13 09:53:15 -0500
commitd4b928f7bb8f66afc31a95fa4552b8fd8fba3712 (patch)
tree689a40f652bd2f784eb1e028340282bdb2f5739b /exit.go
parent915ea4f648f8639cb1fc4111fa49ff298ea79441 (diff)
calls back to the apps' main/argv.go but what next?
Diffstat (limited to 'exit.go')
-rw-r--r--exit.go15
1 files changed, 13 insertions, 2 deletions
diff --git a/exit.go b/exit.go
index 5d629e3..f53c1b6 100644
--- a/exit.go
+++ b/exit.go
@@ -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)
}