diff --git a/agent/exec/errors.go b/agent/exec/errors.go index c973ce2db8..a32a71a992 100644 --- a/agent/exec/errors.go +++ b/agent/exec/errors.go @@ -70,17 +70,14 @@ func (t temporary) Temporary() bool { return true } // IsTemporary returns true if the error or a recursive cause returns true for // temporary. func IsTemporary(err error) bool { - for err != nil { - if tmp, ok := err.(Temporary); ok && tmp.Temporary() { - return true - } + if tmp, ok := err.(Temporary); ok && tmp.Temporary() { + return true + } - cause := errors.Cause(err) - if cause == err { - break - } + cause := errors.Cause(err) - err = cause + if tmp, ok := cause.(Temporary); ok && tmp.Temporary() { + return true } return false