in protocol/dubbo/hessian2/hessian_response.go [175:251]
func unpackResponseBody(decoder *hessian.Decoder, resp interface{}) error {
// body
if decoder == nil {
return perrors.Errorf("@decoder is nil")
}
rspType, err := decoder.Decode()
if err != nil {
return perrors.WithStack(err)
}
response := EnsureResponse(resp)
switch rspType {
case RESPONSE_WITH_EXCEPTION, RESPONSE_WITH_EXCEPTION_WITH_ATTACHMENTS:
expt, err := decoder.Decode()
if err != nil {
return perrors.WithStack(err)
}
if rspType == RESPONSE_WITH_EXCEPTION_WITH_ATTACHMENTS {
attachments, err := decoder.Decode()
if err != nil {
return perrors.WithStack(err)
}
if v, ok := attachments.(map[interface{}]interface{}); ok {
atta := ToMapStringInterface(v)
response.Attachments = atta
} else {
return perrors.Errorf("get wrong attachments: %+v", attachments)
}
}
if e, ok := expt.(error); ok {
response.Exception = e
} else {
response.Exception = perrors.Errorf("got exception: %+v", expt)
}
return nil
case RESPONSE_VALUE, RESPONSE_VALUE_WITH_ATTACHMENTS:
rsp, err := decoder.Decode()
if err != nil {
return perrors.WithStack(err)
}
if rspType == RESPONSE_VALUE_WITH_ATTACHMENTS {
attachments, err := decoder.Decode()
if err != nil {
return perrors.WithStack(err)
}
if v, ok := attachments.(map[interface{}]interface{}); ok {
response.Attachments = ToMapStringInterface(v)
} else {
return perrors.Errorf("get wrong attachments: %+v", attachments)
}
}
response.RspObj = rsp
return nil
case RESPONSE_NULL_VALUE, RESPONSE_NULL_VALUE_WITH_ATTACHMENTS:
if rspType == RESPONSE_NULL_VALUE_WITH_ATTACHMENTS {
attachments, err := decoder.Decode()
if err != nil {
return perrors.WithStack(err)
}
if v, ok := attachments.(map[interface{}]interface{}); ok {
atta := ToMapStringInterface(v)
response.Attachments = atta
} else {
return perrors.Errorf("get wrong attachments: %+v", attachments)
}
}
return nil
}
return nil
}