diff --git a/vngcloud/sdk_error/error_codes.go b/vngcloud/sdk_error/error_codes.go index 8fb7c44..45e54e1 100644 --- a/vngcloud/sdk_error/error_codes.go +++ b/vngcloud/sdk_error/error_codes.go @@ -131,6 +131,7 @@ const ( EcVLBMemberMustIdentical = ErrorCode("VngCloudVLBMemberMustIdentical") EcVLBLoadBalancerExceedQuota = ErrorCode("VngCloudVLBLoadBalancerExceedQuota") EcVLBLoadBalancerIsDeleting = ErrorCode("VngCloudVLBLoadBalancerIsDeleting") + EcVLBLoadBalancerIsCreating = ErrorCode("VngCloudVLBLoadBalancerIsCreating") ) // Endpoint diff --git a/vngcloud/sdk_error/loadbalancer.go b/vngcloud/sdk_error/loadbalancer.go index 93a735a..40180d1 100644 --- a/vngcloud/sdk_error/loadbalancer.go +++ b/vngcloud/sdk_error/loadbalancer.go @@ -21,6 +21,7 @@ const ( patternPoolIsUpdating = `pool id [^.]+ is updating` patternLoadBalancerExceedQuota = "exceeded load_balancer quota. current used" patternLoadBalancerIsDeleting = `load balancer id [^.]+ is deleting` + patternLoadBalancerIsCreating = `load balancer id [^.]+ is creating` ) var ( @@ -28,6 +29,7 @@ var ( regexErrorListenerNotReady = lregexp.MustCompile(patternListenerNotReady) regexErrorPoolIsUpdating = lregexp.MustCompile(patternPoolIsUpdating) regexErrorLoadBalancerIsDeleting = lregexp.MustCompile(patternLoadBalancerIsDeleting) + regexErrorLoadBalancerIsCreating = lregexp.MustCompile(patternLoadBalancerIsCreating) ) func WithErrorLoadBalancerNotFound(perrResp IErrorRespone) func(sdkError IError) { @@ -177,7 +179,7 @@ func WithErrorLoadBalancerIsDeleting(perrResp IErrorRespone) func(sdkError IErro } errMsg := lstr.ToLower(lstr.TrimSpace(perrResp.GetMessage())) - if regexErrorLoadBalancerIsDeleting.FindString(errMsg) != "" { + if regexErrorLoadBalancerIsDeleting.FindString(errMsg) != "" { sdkError.WithErrorCode(EcVLBLoadBalancerIsDeleting). WithMessage(errMsg). WithErrors(perrResp.GetError()) @@ -185,6 +187,21 @@ func WithErrorLoadBalancerIsDeleting(perrResp IErrorRespone) func(sdkError IErro } } +func WithErrorLoadBalancerIsCreating(perrResp IErrorRespone) func(sdkError IError) { + return func(sdkError IError) { + if perrResp == nil { + return + } + + errMsg := lstr.ToLower(lstr.TrimSpace(perrResp.GetMessage())) + if regexErrorLoadBalancerIsCreating.FindString(errMsg) != "" { + sdkError.WithErrorCode(EcVLBLoadBalancerIsCreating). + WithMessage(errMsg). + WithErrors(perrResp.GetError()) + } + } +} + func WithErrorListenerNotFound(perrResp IErrorRespone) func(sdkError IError) { return func(sdkError IError) { if perrResp == nil { diff --git a/vngcloud/services/loadbalancer/v2/loadbalancer.go b/vngcloud/services/loadbalancer/v2/loadbalancer.go index b9dea06..9c230d6 100644 --- a/vngcloud/services/loadbalancer/v2/loadbalancer.go +++ b/vngcloud/services/loadbalancer/v2/loadbalancer.go @@ -270,6 +270,7 @@ func (s *LoadBalancerServiceV2) DeleteLoadBalancerById(popts IDeleteLoadBalancer return lserr.SdkErrorHandler(sdkErr, errResp, lserr.WithErrorLoadBalancerNotFound(errResp), lserr.WithErrorLoadBalancerNotReady(errResp), + lserr.WithErrorLoadBalancerIsCreating(errResp), lserr.WithErrorLoadBalancerIsDeleting(errResp)). WithKVparameters( "loadBalancerId", popts.GetLoadBalancerId(),