Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 避免status_code>=400并且resp为空时err为nil #7264

Merged
merged 1 commit into from Jul 26, 2020

Conversation

ioito
Copy link
Collaborator

@ioito ioito commented Jul 20, 2020

这个 PR 实现什么功能/修复什么问题:
fix: 避免status_code>=400并且resp为空时err为nil

是否需要 backport 到之前的 release 分支:

  • release/3.2

/area region
/cc @zexi

@yunion-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To fully approve this pull request, please assign additional approvers.
We suggest the following additional approver: wanyaoqi

If they are not already assigned, you can assign the PR to them by writing /assign @wanyaoqi in a comment when ready.

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@@ -151,13 +151,10 @@ func (ce *JSONClientError) ParseErrorFromJsonResponse(statusCode int, body jsonu
if err != nil {
return errors.Wrapf(err, "body.Unmarshal(%s)", body.String())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

func (ce *JSONClientError) ParseErrorFromJsonResponse(statusCode int, body jsonutils.JSONObject) error {
body.Unmarshal(ce)
if ce.Code == 0 {
ce.Code = statuacode
}
if len(ce.Class) == 0 {
ce.Class = http.StatusText(statuscode)
}
if len(ce.Details) == 0 {
ce.Details = body.String()
}
return ce
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

无论如何都要返回一个JSONClientError,并且不应该丢失信息

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已更新

@swordqiu
Copy link
Member

/lgtm

1 similar comment
@swordqiu
Copy link
Member

/lgtm

@swordqiu swordqiu requested review from swordqiu and removed request for zexi July 26, 2020 11:02
@swordqiu
Copy link
Member

/lgtm

@swordqiu
Copy link
Member

/approve

2 similar comments
@swordqiu
Copy link
Member

/approve

@swordqiu
Copy link
Member

/approve

@swordqiu
Copy link
Member

/lgtm

@swordqiu
Copy link
Member

/approve

1 similar comment
@swordqiu
Copy link
Member

/approve

@swordqiu
Copy link
Member

/approve

@swordqiu
Copy link
Member

/lgtm

@swordqiu
Copy link
Member

/approve

2 similar comments
@swordqiu
Copy link
Member

/approve

@swordqiu
Copy link
Member

/approve

@swordqiu swordqiu merged commit a67f3e5 into yunionio:master Jul 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants