add unpacker reflect check
This commit is contained in:
parent
05aacd4b8c
commit
668c19eca1
|
@ -78,9 +78,16 @@ func (u *Unpacker) parseResponse() error {
|
|||
}
|
||||
|
||||
func (u *Unpacker) parseError() error {
|
||||
if !u.output.IsValid() {
|
||||
return fmt.Errorf("output fmt error")
|
||||
}
|
||||
retCodeValue := u.output.Elem().FieldByName("RetCode")
|
||||
messageValue := u.output.Elem().FieldByName("Message")
|
||||
|
||||
if !retCodeValue.IsValid() || !messageValue.IsValid() {
|
||||
return fmt.Errorf("can not get retcode/message")
|
||||
}
|
||||
|
||||
if retCodeValue.Elem().IsValid() && retCodeValue.Type().String() == "*int" &&
|
||||
messageValue.Elem().IsValid() && messageValue.Type().String() == "*string" &&
|
||||
retCodeValue.Elem().Int() != 0 {
|
||||
|
|
Loading…
Reference in New Issue