mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-10-28 03:23:25 +08:00
Merge pull request #994 in YUNIONIO/onecloud from ~QIUJIAN/onecloud:hotfix/qj-fix-json-error-parse to release/2.5.0
* commit 'e8445c0d452ec46a9947782b06f3ece1d1cf3253': 修正:httperror没有正确parse错误格式
This commit is contained in:
@@ -229,12 +229,16 @@ func ParseJSONResponse(resp *http.Response, err error, debug bool) (http.Header,
|
||||
ce.Class = "redirect"
|
||||
return nil, nil, &ce
|
||||
} else {
|
||||
ce := JSONClientError{
|
||||
Code: resp.StatusCode,
|
||||
Details: resp.Status,
|
||||
}
|
||||
ce := JSONClientError{}
|
||||
|
||||
if jrbody == nil {
|
||||
ce.Code = resp.StatusCode
|
||||
ce.Details = resp.Status
|
||||
return nil, nil, &ce
|
||||
}
|
||||
|
||||
err = jrbody.Unmarshal(&ce)
|
||||
if len(ce.Class) > 0 && ce.Code >= 400 && len(ce.Details) > 0 {
|
||||
return nil, nil, &ce
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user