Skip to content

Commit

Permalink
[chore] enhance error handler for api create server
Browse files Browse the repository at this point in the history
  • Loading branch information
cuongpiger committed Oct 24, 2024
1 parent 28d98d4 commit 6a3d055
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion vngcloud/sdk_error/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const (
patternServerUpdatingSecgroups = "cannot change security group of server with status changing-security-group"
patternServerExceedCpuQuota = "exceeded vcpu quota. current used"
patternServerImageNotSupported = "doesn't support image with id"
patternImageNotSupport = "don't support image"
patternServerCanNotAttachFloatingIp = "the server only allows attaching 1 floating ip"
)

Expand Down Expand Up @@ -118,7 +119,9 @@ func WithErrorServerImageNotSupported(perrResp IErrorRespone) func(sdkError IErr
}

errMsg := perrResp.GetMessage()
if lstr.Contains(lstr.ToLower(lstr.TrimSpace(errMsg)), patternServerImageNotSupported) {
lowerErrMsg := lstr.ToLower(lstr.TrimSpace(errMsg))
if lstr.Contains(lowerErrMsg, patternServerImageNotSupported) ||
lstr.Contains(lowerErrMsg, patternImageNotSupport) {
sdkError.WithErrorCode(EcVServerServerImageNotSupported).
WithMessage(errMsg).
WithErrors(perrResp.GetError())
Expand Down

0 comments on commit 6a3d055

Please sign in to comment.