处理错误码附加信息为空情况
This commit is contained in:
parent
76377b5e28
commit
a4185295d8
@ -251,6 +251,5 @@ func (this *Agent) messageDistribution(msg *pb.UserMessage) (err error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"reflect"
|
||||
"runtime"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"go_dreamfactory/lego/base"
|
||||
"go_dreamfactory/lego/core"
|
||||
@ -117,27 +118,30 @@ func (this *SCompGateRoute) ReceiveMsg(ctx context.Context, args *pb.AgentMessag
|
||||
//序列化用户消息对象
|
||||
var msg proto.Message
|
||||
if msg, err = args.Message.UnmarshalNew(); err != nil {
|
||||
log.Errorf("UserMessage:%s Unmarshal err:%v", method, err)
|
||||
log.Errorf("[Handle Api] UserMessage:%s Unmarshal err:%v", method, err)
|
||||
return err
|
||||
}
|
||||
|
||||
//执行处理流
|
||||
log.Debugf("ReceiveMsg Message:[%s-%s]-%v user[%s-%s]", args.MainType, args.SubType, msg, args.UserSessionId, args.UserId)
|
||||
stime := time.Now()
|
||||
handlereturn := msghandle.handle.Func.Call([]reflect.Value{msghandle.rcvr, reflect.ValueOf(session), reflect.ValueOf(msg)})
|
||||
log.Debugf("[Handle Api] consumetime:%v method:%s uid:%s msg:%v", time.Since(stime), method, args.UserId, msg)
|
||||
errcode := pb.ErrorCode(handlereturn[0].Int())
|
||||
errdata := handlereturn[0].Interface().(proto.Message)
|
||||
data, _ := anypb.New(errdata)
|
||||
errdata := handlereturn[0].Interface()
|
||||
if errcode != pb.ErrorCode_Success { //处理返货错误码 返回用户错误信息
|
||||
log.Errorf("HandleUserMsg:%s msg:%v code:%d", method, msg, errcode)
|
||||
log.Errorf("[Handle Api] method:%s uid:%s msg:%v code:%d", method, msg, errcode)
|
||||
reply.Code = errcode
|
||||
reply.ErrorMessage = pb.GetErrorCodeMsg(errcode)
|
||||
reply.ErrorData = data
|
||||
if errdata != nil {
|
||||
data, _ := anypb.New(errdata.(proto.Message))
|
||||
reply.ErrorData = data
|
||||
}
|
||||
return nil
|
||||
} else {
|
||||
reply.Reply = session.Polls()
|
||||
}
|
||||
} else { //未找到消息处理函数
|
||||
log.Errorf("no found handle %s", method)
|
||||
log.Errorf("[Handle Api] no found handle %s", method)
|
||||
reply.Code = pb.ErrorCode_ReqParameterError
|
||||
}
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user