Merge pull request #97 from cygnushan/fix-UnpackHTTPRequest-panic
Fix unpack http request panic
This commit is contained in:
commit
05aacd4b8c
|
@ -81,8 +81,8 @@ func (u *Unpacker) parseError() error {
|
|||
retCodeValue := u.output.Elem().FieldByName("RetCode")
|
||||
messageValue := u.output.Elem().FieldByName("Message")
|
||||
|
||||
if retCodeValue.IsValid() && retCodeValue.Type().String() == "*int" &&
|
||||
messageValue.IsValid() && messageValue.Type().String() == "*string" &&
|
||||
if retCodeValue.Elem().IsValid() && retCodeValue.Type().String() == "*int" &&
|
||||
messageValue.Elem().IsValid() && messageValue.Type().String() == "*string" &&
|
||||
retCodeValue.Elem().Int() != 0 {
|
||||
|
||||
return &errors.QingCloudError{
|
||||
|
|
|
@ -79,6 +79,7 @@ func TestUnpackerUnpackHTTPRequest(t *testing.T) {
|
|||
RetCode *int `json:"ret_code" name:"ret_code"`
|
||||
TotalCount *int `json:"total_count" name:"total_count"`
|
||||
VolumeSet []*Volume `json:"volume_set" name:"volume_set"`
|
||||
Message *string `json:"message" name:"message"`
|
||||
}
|
||||
|
||||
httpResponse := &http.Response{Header: http.Header{}}
|
||||
|
|
Loading…
Reference in New Issue