错误监听
This commit is contained in:
parent
64980cb107
commit
2f26e7ab3d
@ -8,6 +8,7 @@ import (
|
|||||||
"go_dreamfactory/sys/configure"
|
"go_dreamfactory/sys/configure"
|
||||||
"go_dreamfactory/sys/db"
|
"go_dreamfactory/sys/db"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"runtime"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -118,15 +119,15 @@ func (this *SCompGateRoute) RegisterRoute(methodName string, comp reflect.Value,
|
|||||||
//Rpc_GatewayRoute服务接口的接收函数
|
//Rpc_GatewayRoute服务接口的接收函数
|
||||||
func (this *SCompGateRoute) ReceiveMsg(ctx context.Context, args *pb.AgentMessage, reply *pb.RPCMessageReply) (err error) {
|
func (this *SCompGateRoute) ReceiveMsg(ctx context.Context, args *pb.AgentMessage, reply *pb.RPCMessageReply) (err error) {
|
||||||
method := fmt.Sprintf("%s.%s", args.MainType, args.SubType)
|
method := fmt.Sprintf("%s.%s", args.MainType, args.SubType)
|
||||||
// defer func() { //程序异常 收集异常信息传递给前端显示
|
defer func() { //程序异常 收集异常信息传递给前端显示
|
||||||
// if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
// buf := make([]byte, 4096)
|
buf := make([]byte, 4096)
|
||||||
// l := runtime.Stack(buf, false)
|
l := runtime.Stack(buf, false)
|
||||||
// reply.Code = pb.ErrorCode_Exception
|
reply.Code = pb.ErrorCode_Exception
|
||||||
// reply.ErrorMessage = fmt.Sprintf("%v: %s", r, buf[:l])
|
reply.ErrorMessage = fmt.Sprintf("%v: %s", r, buf[:l])
|
||||||
// log.Errorf("[Handle Api] m:%s reply:%s", method, reply)
|
log.Errorf("[Handle Api] m:%s reply:%s", method, reply)
|
||||||
// }
|
}
|
||||||
// }()
|
}()
|
||||||
//获取用户消息处理函数
|
//获取用户消息处理函数
|
||||||
this.mrlock.RLock()
|
this.mrlock.RLock()
|
||||||
msghandle, ok := this.msghandles[method]
|
msghandle, ok := this.msghandles[method]
|
||||||
|
Loading…
Reference in New Issue
Block a user