Skip to content

Commit

Permalink
[build] upgrade vngcloud-go-sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
cuongpiger committed Aug 29, 2024
1 parent 4bc8cdb commit 6d64bf0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions vngcloud/sdk_error/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,20 +113,25 @@ func WithErrorPagingInvalid(perrResp IErrorRespone) func(sdkError IError) {
func WithErrorUnexpected(presponse *lreq.Response) func(IError) {
statusCode := 0
url := ""
err := lfmt.Errorf("unexpected error from making request to external service")
if presponse != nil {
if presponse.StatusCode != 0 {
if presponse.Response != nil && presponse.StatusCode != 0 {
statusCode = presponse.StatusCode
}

if presponse.Request != nil && presponse.Request.URL != nil {
url = presponse.Request.URL.String()
}

if presponse.Err != nil {
err = presponse.Err
}
}

return func(sdkErr IError) {
sdkErr.WithErrorCode(EcUnexpectedError).
WithMessage("Unexpected Error").
WithErrors(lfmt.Errorf("unexpected error from making request to external service")).
WithErrors(err).
WithParameters(map[string]interface{}{
"statusCode": statusCode,
"url": url,
Expand Down

0 comments on commit 6d64bf0

Please sign in to comment.