mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 14:19:49 +08:00
Automatic merge from release/2.1.0 -> release/2.2.0
* commit 'ed401039b38d16546d674b07869e92e40f20ceeb': 阿里云错误处理
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/compute/models"
|
||||
"yunion.io/x/pkg/utils"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -72,8 +73,12 @@ func _jsonRequest(client *sdk.Client, domain string, version string, apiName str
|
||||
return nil, err
|
||||
}
|
||||
//{"Code":"InvalidInstanceType.ValueNotSupported","HostId":"ecs.aliyuncs.com","Message":"The specified instanceType beyond the permitted range.","RequestId":"0042EE30-0EDF-48A7-A414-56229D4AD532"}
|
||||
//{"Code":"200","Message":"successful","PageNumber":1,"PageSize":50,"RequestId":"BB4C970C-0E23-48DC-A3B0-EB21FFC70A29","RouterTableList":{"RouterTableListType":[{"CreationTime":"2017-03-19T13:37:40Z","Description":"","ResourceGroupId":"rg-acfmwie3cqoobmi","RouteTableId":"vtb-j6c60lectdi80rk5xz43g","RouteTableName":"","RouteTableType":"System","RouterId":"vrt-j6c00qrol733dg36iq4qj","RouterType":"VRouter","VSwitchIds":{"VSwitchId":["vsw-j6c3gig5ub4fmi2veyrus"]},"VpcId":"vpc-j6c86z3sh8ufhgsxwme0q"}]},"Success":true,"TotalCount":1}
|
||||
if body.Contains("Code") {
|
||||
return nil, fmt.Errorf(body.String())
|
||||
code, _ := body.GetString("Code")
|
||||
if len(code) > 0 && !utils.IsInStringArray(code, []string{"200"}) {
|
||||
return nil, fmt.Errorf(body.String())
|
||||
}
|
||||
}
|
||||
return body, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user