diff --git a/services/comp_gateroute.go b/services/comp_gateroute.go index 1f87e10f4..f80306a86 100644 --- a/services/comp_gateroute.go +++ b/services/comp_gateroute.go @@ -8,6 +8,7 @@ import ( "go_dreamfactory/sys/configure" "go_dreamfactory/sys/db" "reflect" + "runtime" "sync" "time" @@ -118,15 +119,15 @@ func (this *SCompGateRoute) RegisterRoute(methodName string, comp reflect.Value, //Rpc_GatewayRoute服务接口的接收函数 func (this *SCompGateRoute) ReceiveMsg(ctx context.Context, args *pb.AgentMessage, reply *pb.RPCMessageReply) (err error) { method := fmt.Sprintf("%s.%s", args.MainType, args.SubType) - // defer func() { //程序异常 收集异常信息传递给前端显示 - // if r := recover(); r != nil { - // buf := make([]byte, 4096) - // l := runtime.Stack(buf, false) - // reply.Code = pb.ErrorCode_Exception - // reply.ErrorMessage = fmt.Sprintf("%v: %s", r, buf[:l]) - // log.Errorf("[Handle Api] m:%s reply:%s", method, reply) - // } - // }() + defer func() { //程序异常 收集异常信息传递给前端显示 + if r := recover(); r != nil { + buf := make([]byte, 4096) + l := runtime.Stack(buf, false) + reply.Code = pb.ErrorCode_Exception + reply.ErrorMessage = fmt.Sprintf("%v: %s", r, buf[:l]) + log.Errorf("[Handle Api] m:%s reply:%s", method, reply) + } + }() //获取用户消息处理函数 this.mrlock.RLock() msghandle, ok := this.msghandles[method]