|
|
@@ -22,9 +22,11 @@ import (
|
|
|
"net/http"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
+ "github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors"
|
|
|
)
|
|
|
|
|
|
type AcsResponse interface {
|
|
|
+ IsSuccess() bool
|
|
|
GetHttpStatus() int
|
|
|
GetHttpHeaders() map[string][]string
|
|
|
GetHttpContentString() string
|
|
|
@@ -38,6 +40,10 @@ func Unmarshal(response AcsResponse, httpResponse *http.Response, format string)
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
+ if !response.IsSuccess() {
|
|
|
+ err = errors.NewServerError(response.GetHttpStatus(), response.GetOriginHttpResponse().Status, response.GetHttpContentString())
|
|
|
+ return
|
|
|
+ }
|
|
|
if strings.ToUpper(format) == "JSON" {
|
|
|
err = json.Unmarshal(response.GetHttpContentBytes(), response)
|
|
|
} else if strings.ToUpper(format) == "XML" {
|