From d4b928f7bb8f66afc31a95fa4552b8fd8fba3712 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Mon, 13 Oct 2025 09:53:15 -0500 Subject: calls back to the apps' main/argv.go but what next? --- exit.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'exit.go') 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) } -- cgit v1.2.3