Open
Description
There are several places in code that propagate textual error LATTICE_RETRY, discarding underlying error. For example:
// also check the status, disassociation is still in progress, retry later
if aws.StringValue(svcServiceNetworkOutput.Status) == vpclattice.ServiceNetworkServiceAssociationStatusDeleteInProgress {
glog.V(6).Infof("Disassociate-in-progress will retry later service %v from service network %v",
snAssocResp.ServiceName, snAssocResp.ServiceNetworkName)
return errors.New(LATTICE_RETRY)
}
So we dump error cause into debug trace, and return Retry error. And then up in stack we do text based assertion on the error to see if it's Retry error.
We can just concatenate errors and let "errors.As" or "errors.Is" figure out if it's a retry error.
var LATTICE_RETRY = errors.New("lattice_retry")
func main() {
err1 := errors.New("a true error")
err2 := fmt.Errorf("gateway controller: %s", err1)
retErr := fmt.Errorf("%w: %s", LATTICE_RETRY, err2)
fmt.Printf("retErr=%s\n", retErr)
isRetry := errors.Is(retErr, LATTICE_RETRY)
fmt.Printf("is retry error? %t\n", isRetry)
}
// will produce
retErr=lattice_retry: gateway controller: a true error
is retry error? true