From 9b3226a80a35ee85eebb6d910f9608dc301f0e72 Mon Sep 17 00:00:00 2001 From: Nalin Dahyabhai Date: Wed, 14 Apr 2021 13:38:27 -0400 Subject: pkg/errorhandling.JoinErrors: don't throw away context for lone errors When our multierror contains just one error, don't extract its text only to rewrap it, because doing so discards any stack trace information that might have been added closer to where the error actually originated. Signed-off-by: Nalin Dahyabhai --- pkg/errorhandling/errorhandling.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'pkg/errorhandling') diff --git a/pkg/errorhandling/errorhandling.go b/pkg/errorhandling/errorhandling.go index b1923be98..9dc545ebb 100644 --- a/pkg/errorhandling/errorhandling.go +++ b/pkg/errorhandling/errorhandling.go @@ -24,6 +24,9 @@ func JoinErrors(errs []error) error { if finalErr == nil { return finalErr } + if len(multiE.WrappedErrors()) == 1 && logrus.IsLevelEnabled(logrus.TraceLevel) { + return multiE.WrappedErrors()[0] + } return errors.New(strings.TrimSpace(finalErr.Error())) } -- cgit v1.2.3-54-g00ecf