用户执行连异常捕捉 推送客户端
This commit is contained in:
parent
10941376f1
commit
7c09e141cd
@ -23,20 +23,21 @@ const (
|
|||||||
type ErrorCode int32
|
type ErrorCode int32
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ErrorCode_Success ErrorCode = 0 //成功
|
ErrorCode_Success ErrorCode = 0 //成功
|
||||||
ErrorCode_NoFindService ErrorCode = 10 //没有找到远程服务器
|
ErrorCode_NoFindService ErrorCode = 10 //没有找到远程服务器
|
||||||
ErrorCode_NoFindServiceHandleFunc ErrorCode = 11 //远程服务器未找到执行方法
|
ErrorCode_NoFindServiceHandleFunc ErrorCode = 11 //远程服务器未找到执行方法
|
||||||
ErrorCode_RpcFuncExecutionError ErrorCode = 12 //Rpc方法执行错误
|
ErrorCode_RpcFuncExecutionError ErrorCode = 12 //Rpc方法执行错误
|
||||||
ErrorCode_CacheReadError ErrorCode = 13 //缓存读取失败
|
ErrorCode_CacheReadError ErrorCode = 13 //缓存读取失败
|
||||||
ErrorCode_SqlExecutionError ErrorCode = 14 //数据库执行错误
|
ErrorCode_SqlExecutionError ErrorCode = 14 //数据库执行错误
|
||||||
ErrorCode_ReqParameterError ErrorCode = 15 //请求参数错误
|
ErrorCode_ReqParameterError ErrorCode = 15 //请求参数错误
|
||||||
ErrorCode_SignError ErrorCode = 16 //签名错误
|
ErrorCode_SignError ErrorCode = 16 //签名错误
|
||||||
ErrorCode_InsufficientPermissions ErrorCode = 17 //权限不足
|
ErrorCode_InsufficientPermissions ErrorCode = 17 //权限不足
|
||||||
ErrorCode_NoLogin ErrorCode = 18 //未登录
|
ErrorCode_NoLogin ErrorCode = 18 //未登录
|
||||||
ErrorCode_UserSessionNobeing ErrorCode = 19 //用户不存在
|
ErrorCode_UserSessionNobeing ErrorCode = 19 //用户不存在
|
||||||
ErrorCode_StateInvalid ErrorCode = 20 //无效状态
|
ErrorCode_StateInvalid ErrorCode = 20 //无效状态
|
||||||
ErrorCode_DBError ErrorCode = 21 // 数据库操作失败
|
ErrorCode_DBError ErrorCode = 21 // 数据库操作失败
|
||||||
ErrorCode_SystemError ErrorCode = 22 // 通用错误
|
ErrorCode_SystemError ErrorCode = 22 // 通用错误
|
||||||
|
ErrorCode_Exception ErrorCode = 100 //程序执行异常
|
||||||
//user
|
//user
|
||||||
ErrorCode_SecKeyInvalid ErrorCode = 1000 //秘钥无效
|
ErrorCode_SecKeyInvalid ErrorCode = 1000 //秘钥无效
|
||||||
ErrorCode_SecKey ErrorCode = 1001 //秘钥格式错误
|
ErrorCode_SecKey ErrorCode = 1001 //秘钥格式错误
|
||||||
@ -71,6 +72,7 @@ var (
|
|||||||
20: "StateInvalid",
|
20: "StateInvalid",
|
||||||
21: "DBError",
|
21: "DBError",
|
||||||
22: "SystemError",
|
22: "SystemError",
|
||||||
|
100: "Exception",
|
||||||
1000: "SecKeyInvalid",
|
1000: "SecKeyInvalid",
|
||||||
1001: "SecKey",
|
1001: "SecKey",
|
||||||
1100: "FriendNotSelf",
|
1100: "FriendNotSelf",
|
||||||
@ -100,6 +102,7 @@ var (
|
|||||||
"StateInvalid": 20,
|
"StateInvalid": 20,
|
||||||
"DBError": 21,
|
"DBError": 21,
|
||||||
"SystemError": 22,
|
"SystemError": 22,
|
||||||
|
"Exception": 100,
|
||||||
"SecKeyInvalid": 1000,
|
"SecKeyInvalid": 1000,
|
||||||
"SecKey": 1001,
|
"SecKey": 1001,
|
||||||
"FriendNotSelf": 1100,
|
"FriendNotSelf": 1100,
|
||||||
@ -147,7 +150,7 @@ var File_errorcode_proto protoreflect.FileDescriptor
|
|||||||
|
|
||||||
var file_errorcode_proto_rawDesc = []byte{
|
var file_errorcode_proto_rawDesc = []byte{
|
||||||
0x0a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
0x0a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||||
0x6f, 0x2a, 0xba, 0x04, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12,
|
0x6f, 0x2a, 0xc9, 0x04, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12,
|
||||||
0x0b, 0x0a, 0x07, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d,
|
0x0b, 0x0a, 0x07, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d,
|
||||||
0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x10, 0x0a, 0x12,
|
0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x10, 0x0a, 0x12,
|
||||||
0x1b, 0x0a, 0x17, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
|
0x1b, 0x0a, 0x17, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
|
||||||
@ -165,25 +168,26 @@ var file_errorcode_proto_rawDesc = []byte{
|
|||||||
0x6e, 0x4e, 0x6f, 0x62, 0x65, 0x69, 0x6e, 0x67, 0x10, 0x13, 0x12, 0x10, 0x0a, 0x0c, 0x53, 0x74,
|
0x6e, 0x4e, 0x6f, 0x62, 0x65, 0x69, 0x6e, 0x67, 0x10, 0x13, 0x12, 0x10, 0x0a, 0x0c, 0x53, 0x74,
|
||||||
0x61, 0x74, 0x65, 0x49, 0x6e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x10, 0x14, 0x12, 0x0b, 0x0a, 0x07,
|
0x61, 0x74, 0x65, 0x49, 0x6e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x10, 0x14, 0x12, 0x0b, 0x0a, 0x07,
|
||||||
0x44, 0x42, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0x15, 0x12, 0x0f, 0x0a, 0x0b, 0x53, 0x79, 0x73,
|
0x44, 0x42, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0x15, 0x12, 0x0f, 0x0a, 0x0b, 0x53, 0x79, 0x73,
|
||||||
0x74, 0x65, 0x6d, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0x16, 0x12, 0x12, 0x0a, 0x0d, 0x53, 0x65,
|
0x74, 0x65, 0x6d, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0x16, 0x12, 0x0d, 0x0a, 0x09, 0x45, 0x78,
|
||||||
0x63, 0x4b, 0x65, 0x79, 0x49, 0x6e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x10, 0xe8, 0x07, 0x12, 0x0b,
|
0x63, 0x65, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x10, 0x64, 0x12, 0x12, 0x0a, 0x0d, 0x53, 0x65, 0x63,
|
||||||
0x0a, 0x06, 0x53, 0x65, 0x63, 0x4b, 0x65, 0x79, 0x10, 0xe9, 0x07, 0x12, 0x12, 0x0a, 0x0d, 0x46,
|
0x4b, 0x65, 0x79, 0x49, 0x6e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x10, 0xe8, 0x07, 0x12, 0x0b, 0x0a,
|
||||||
0x72, 0x69, 0x65, 0x6e, 0x64, 0x4e, 0x6f, 0x74, 0x53, 0x65, 0x6c, 0x66, 0x10, 0xcc, 0x08, 0x12,
|
0x06, 0x53, 0x65, 0x63, 0x4b, 0x65, 0x79, 0x10, 0xe9, 0x07, 0x12, 0x12, 0x0a, 0x0d, 0x46, 0x72,
|
||||||
0x12, 0x0a, 0x0d, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x53, 0x65, 0x6c, 0x66, 0x4d, 0x61, 0x78,
|
0x69, 0x65, 0x6e, 0x64, 0x4e, 0x6f, 0x74, 0x53, 0x65, 0x6c, 0x66, 0x10, 0xcc, 0x08, 0x12, 0x12,
|
||||||
0x10, 0xcd, 0x08, 0x12, 0x14, 0x0a, 0x0f, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x54, 0x61, 0x72,
|
0x0a, 0x0d, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x53, 0x65, 0x6c, 0x66, 0x4d, 0x61, 0x78, 0x10,
|
||||||
0x67, 0x65, 0x74, 0x4d, 0x61, 0x78, 0x10, 0xce, 0x08, 0x12, 0x15, 0x0a, 0x10, 0x46, 0x72, 0x69,
|
0xcd, 0x08, 0x12, 0x14, 0x0a, 0x0f, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x54, 0x61, 0x72, 0x67,
|
||||||
0x65, 0x6e, 0x64, 0x53, 0x65, 0x6c, 0x66, 0x4e, 0x6f, 0x44, 0x61, 0x74, 0x61, 0x10, 0xcf, 0x08,
|
0x65, 0x74, 0x4d, 0x61, 0x78, 0x10, 0xce, 0x08, 0x12, 0x15, 0x0a, 0x10, 0x46, 0x72, 0x69, 0x65,
|
||||||
0x12, 0x17, 0x0a, 0x12, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74,
|
0x6e, 0x64, 0x53, 0x65, 0x6c, 0x66, 0x4e, 0x6f, 0x44, 0x61, 0x74, 0x61, 0x10, 0xcf, 0x08, 0x12,
|
||||||
0x4e, 0x6f, 0x44, 0x61, 0x74, 0x61, 0x10, 0xd0, 0x08, 0x12, 0x0e, 0x0a, 0x09, 0x46, 0x72, 0x69,
|
0x17, 0x0a, 0x12, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x4e,
|
||||||
0x65, 0x6e, 0x64, 0x59, 0x65, 0x74, 0x10, 0xd1, 0x08, 0x12, 0x13, 0x0a, 0x0e, 0x46, 0x72, 0x69,
|
0x6f, 0x44, 0x61, 0x74, 0x61, 0x10, 0xd0, 0x08, 0x12, 0x0e, 0x0a, 0x09, 0x46, 0x72, 0x69, 0x65,
|
||||||
0x65, 0x6e, 0x64, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x59, 0x65, 0x74, 0x10, 0xd2, 0x08, 0x12, 0x17,
|
0x6e, 0x64, 0x59, 0x65, 0x74, 0x10, 0xd1, 0x08, 0x12, 0x13, 0x0a, 0x0e, 0x46, 0x72, 0x69, 0x65,
|
||||||
0x0a, 0x12, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x53, 0x65, 0x6c, 0x66, 0x42, 0x6c, 0x61, 0x63,
|
0x6e, 0x64, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x59, 0x65, 0x74, 0x10, 0xd2, 0x08, 0x12, 0x17, 0x0a,
|
||||||
0x6b, 0x59, 0x65, 0x74, 0x10, 0xd3, 0x08, 0x12, 0x19, 0x0a, 0x14, 0x46, 0x72, 0x69, 0x65, 0x6e,
|
0x12, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x53, 0x65, 0x6c, 0x66, 0x42, 0x6c, 0x61, 0x63, 0x6b,
|
||||||
0x64, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x59, 0x65, 0x74, 0x10,
|
0x59, 0x65, 0x74, 0x10, 0xd3, 0x08, 0x12, 0x19, 0x0a, 0x14, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64,
|
||||||
0xd4, 0x08, 0x12, 0x15, 0x0a, 0x10, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x41, 0x70, 0x70, 0x6c,
|
0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x59, 0x65, 0x74, 0x10, 0xd4,
|
||||||
0x79, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0xd5, 0x08, 0x12, 0x13, 0x0a, 0x0e, 0x46, 0x72, 0x69,
|
0x08, 0x12, 0x15, 0x0a, 0x10, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x41, 0x70, 0x70, 0x6c, 0x79,
|
||||||
0x65, 0x6e, 0x64, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x4d, 0x61, 0x78, 0x10, 0xd6, 0x08, 0x42, 0x06,
|
0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0xd5, 0x08, 0x12, 0x13, 0x0a, 0x0e, 0x46, 0x72, 0x69, 0x65,
|
||||||
0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
0x6e, 0x64, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x4d, 0x61, 0x78, 0x10, 0xd6, 0x08, 0x42, 0x06, 0x5a,
|
||||||
|
0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -17,6 +17,7 @@ enum ErrorCode {
|
|||||||
StateInvalid = 20; //无效状态
|
StateInvalid = 20; //无效状态
|
||||||
DBError = 21; // 数据库操作失败
|
DBError = 21; // 数据库操作失败
|
||||||
SystemError = 22; // 通用错误
|
SystemError = 22; // 通用错误
|
||||||
|
Exception = 100; //程序执行异常
|
||||||
|
|
||||||
//user
|
//user
|
||||||
SecKeyInvalid = 1000; //秘钥无效
|
SecKeyInvalid = 1000; //秘钥无效
|
||||||
|
@ -2,9 +2,11 @@ package services
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"runtime"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
jsoniter "github.com/json-iterator/go"
|
jsoniter "github.com/json-iterator/go"
|
||||||
@ -117,6 +119,15 @@ func (this *SComp_GateRouteComp) RegisterRouteCheck(methodName string, comp refl
|
|||||||
|
|
||||||
//Rpc_GatewayRoute服务接口的接收函数
|
//Rpc_GatewayRoute服务接口的接收函数
|
||||||
func (this *SComp_GateRouteComp) ReceiveMsg(ctx context.Context, args *pb.AgentMessage, reply *pb.RPCMessageReply) error {
|
func (this *SComp_GateRouteComp) ReceiveMsg(ctx context.Context, args *pb.AgentMessage, reply *pb.RPCMessageReply) error {
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
buf := make([]byte, 1024)
|
||||||
|
l := runtime.Stack(buf, false)
|
||||||
|
reply.Code = pb.ErrorCode_Exception
|
||||||
|
reply.Message = fmt.Sprintf("%v: %s", r, buf[:l])
|
||||||
|
log.Errorf("HandleUserMsg:%s err:%s", args.Method, reply.Message)
|
||||||
|
}
|
||||||
|
}()
|
||||||
log.Debugf("SComp_GateRouteComp ReceiveMsg agent:%s uId:%s MessageDistribution msg:%s", args.UserSessionId, args.UserId, args.Method)
|
log.Debugf("SComp_GateRouteComp ReceiveMsg agent:%s uId:%s MessageDistribution msg:%s", args.UserSessionId, args.UserId, args.Method)
|
||||||
this.mrlock.RLock()
|
this.mrlock.RLock()
|
||||||
msghandle, ok := this.msghandles[args.Method]
|
msghandle, ok := this.msghandles[args.Method]
|
||||||
|
Loading…
Reference in New Issue
Block a user