修正:httperror没有正确parse错误格式

This commit is contained in:
Qiu Jian
2019-01-27 18:50:29 +08:00
parent a05b1e817e
commit e8445c0d45
2 changed files with 11 additions and 5 deletions
+3 -1
View File
@@ -128,7 +128,9 @@ getent passwd %{owner} >/dev/null || /usr/sbin/useradd -r -s /sbin/nologin -d %{
$(for b in $EXTRA_BINS; do echo /opt/yunion/bin/$b; done)
" > $SPEC_FILE
find $ROOT/root/ -type f | sed -e "s:$ROOT/root::g" >> $SPEC_FILE
if [ -d $ROOT/root/ ]; then
find $ROOT/root/ -type f | sed -e "s:$ROOT/root::g" >> $SPEC_FILE
fi
rpmbuild --define "_topdir $BUILDROOT" -bb $SPEC_FILE
+8 -4
View File
@@ -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
}