-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d81932c
commit ad2e635
Showing
9 changed files
with
204 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package sdk_error | ||
|
||
import lstr "strings" | ||
|
||
const ( | ||
patternServerNotFound = "cannot get server with id" // "Cannot get volume type with id vtype-6790f903-38d2-454d-919e-5b49184b5927" | ||
patternServerCreating = "cannot delete server with status creating" // "Server is creating" | ||
) | ||
|
||
func WithErrorServerNotFound(perrResp IErrorRespone) func(sdkError ISdkError) { | ||
return func(sdkError ISdkError) { | ||
if perrResp == nil { | ||
return | ||
} | ||
|
||
errMsg := perrResp.GetMessage() | ||
if lstr.Contains(lstr.ToLower(lstr.TrimSpace(errMsg)), patternServerNotFound) { | ||
sdkError.WithErrorCode(EcVServerServerNotFound). | ||
WithMessage(errMsg). | ||
WithErrors(perrResp.GetError()) | ||
} | ||
} | ||
} | ||
|
||
func WithErrorServerDeleteCreatingServer(perrResp IErrorRespone) func(sdkError ISdkError) { | ||
return func(sdkError ISdkError) { | ||
if perrResp == nil { | ||
return | ||
} | ||
|
||
errMsg := perrResp.GetMessage() | ||
if lstr.Contains(lstr.ToLower(lstr.TrimSpace(errMsg)), patternServerCreating) { | ||
sdkError.WithErrorCode(EcVServerServerDeleteCreatingServer). | ||
WithMessage(errMsg). | ||
WithErrors(perrResp.GetError()) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters