diff --git a/vngcloud/sdk_error/endpoint.go b/vngcloud/sdk_error/endpoint.go index 285ffe5..267f74b 100644 --- a/vngcloud/sdk_error/endpoint.go +++ b/vngcloud/sdk_error/endpoint.go @@ -84,4 +84,18 @@ func WithErrorEndpointTagNotFound(perrResp IErrorRespone) func(sdkError IError) WithErrors(perrResp.GetError()) } } +} + +func WithErrorEndpointTagExisted(perrResp IErrorRespone) func(sdkError IError) { + return func(sdkError IError) { + if perrResp == nil { + return + } + + if lstr.ToUpper(lstr.TrimSpace(perrResp.GetError().Error())) == "TAG_EXISTED" { + sdkError.WithErrorCode(EcVNetworkEndpointTagExisted). + WithMessage(perrResp.GetMessage()). + WithErrors(perrResp.GetError()) + } + } } \ No newline at end of file diff --git a/vngcloud/sdk_error/error_codes.go b/vngcloud/sdk_error/error_codes.go index 1dcefa8..78049b6 100644 --- a/vngcloud/sdk_error/error_codes.go +++ b/vngcloud/sdk_error/error_codes.go @@ -154,4 +154,5 @@ const ( EcVNetworkContainInvalidCharacter = ErrorCode("ContainInvalidCharacter") EcVNetworkLockOnProcess = ErrorCode("LockOnProcess") EcVNetworkEndpointTagNotFound = ErrorCode("EndpointTagNotFound") + EcVNetworkEndpointTagExisted = ErrorCode("EndpointTagExisted") ) diff --git a/vngcloud/services/network/v1/endpoint.go b/vngcloud/services/network/v1/endpoint.go index cb10678..c73489d 100644 --- a/vngcloud/services/network/v1/endpoint.go +++ b/vngcloud/services/network/v1/endpoint.go @@ -124,6 +124,7 @@ func (s *NetworkServiceInternalV1) CreateTagsWithEndpointId(popts ICreateTagsWit if _, sdkErr := s.VNetworkClient.Post(url, req); sdkErr != nil { return lserr.SdkErrorHandler(sdkErr, errResp, + lserr.WithErrorEndpointTagExisted(errResp), lserr.WithErrorEndpointTagNotFound(errResp)). WithKVparameters("projectId", s.getProjectId()). WithParameters(popts.GetParameters())