上传错误信息数据返回前端

This commit is contained in:
liwei1dao 2023-04-14 10:42:58 +08:00
parent 02a20470d5
commit a0d29a277e
3 changed files with 91 additions and 16 deletions

View File

@ -1,6 +1,7 @@
package atlas
import (
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
@ -37,6 +38,7 @@ func (this *apiComp) Award(session comm.IUserSession, req *pb.AtlasAwardReq) (co
return
}
if code = this.module.DispenseRes(session, res, true); code != pb.ErrorCode_Success {
data = &pb.ErrorData{Pstring: fmt.Sprintf("%v", res)}
return
}

View File

@ -366,6 +366,7 @@ func (this *Agent) messageDistribution(msg *pb.UserMessage) (err error) {
ReqMainType: msg.MainType,
ReqSubType: msg.SubType,
Arg: msg.Data,
Data: reply.ErrorData,
Code: pb.ErrorCode(reply.Code.Number())})
err = this.WriteMsg(&pb.UserMessage{
MainType: comm.MainTypeNotify,

View File

@ -1853,6 +1853,61 @@ func (x *ServiceDBInfo) GetMongodbDatabase() string {
return ""
}
type ErrorData struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Pint int32 `protobuf:"varint,1,opt,name=pint,proto3" json:"pint"`
Pstring string `protobuf:"bytes,2,opt,name=pstring,proto3" json:"pstring"`
}
func (x *ErrorData) Reset() {
*x = ErrorData{}
if protoimpl.UnsafeEnabled {
mi := &file_comm_proto_msgTypes[27]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ErrorData) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ErrorData) ProtoMessage() {}
func (x *ErrorData) ProtoReflect() protoreflect.Message {
mi := &file_comm_proto_msgTypes[27]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ErrorData.ProtoReflect.Descriptor instead.
func (*ErrorData) Descriptor() ([]byte, []int) {
return file_comm_proto_rawDescGZIP(), []int{27}
}
func (x *ErrorData) GetPint() int32 {
if x != nil {
return x.Pint
}
return 0
}
func (x *ErrorData) GetPstring() string {
if x != nil {
return x.Pstring
}
return ""
}
var File_comm_proto protoreflect.FileDescriptor
var file_comm_proto_rawDesc = []byte{
@ -2045,12 +2100,16 @@ var file_comm_proto_rawDesc = []byte{
0x52, 0x0a, 0x4d, 0x6f, 0x6e, 0x67, 0x6f, 0x64, 0x62, 0x55, 0x72, 0x6c, 0x12, 0x28, 0x0a, 0x0f,
0x6d, 0x6f, 0x6e, 0x67, 0x6f, 0x64, 0x62, 0x44, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x18,
0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x6d, 0x6f, 0x6e, 0x67, 0x6f, 0x64, 0x62, 0x44, 0x61,
0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x2a, 0x43, 0x0a, 0x12, 0x48, 0x65, 0x72, 0x6f, 0x41, 0x74,
0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73, 0x54, 0x79, 0x70, 0x65, 0x12, 0x06, 0x0a, 0x02,
0x48, 0x70, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x74, 0x6b, 0x10, 0x01, 0x12, 0x07, 0x0a,
0x03, 0x44, 0x65, 0x66, 0x10, 0x02, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x70, 0x65, 0x65, 0x64, 0x10,
0x03, 0x12, 0x08, 0x0a, 0x04, 0x43, 0x72, 0x69, 0x74, 0x10, 0x04, 0x42, 0x06, 0x5a, 0x04, 0x2e,
0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x22, 0x39, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x44,
0x61, 0x74, 0x61, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x69, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28,
0x05, 0x52, 0x04, 0x70, 0x69, 0x6e, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x73, 0x74, 0x72, 0x69,
0x6e, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x73, 0x74, 0x72, 0x69, 0x6e,
0x67, 0x2a, 0x43, 0x0a, 0x12, 0x48, 0x65, 0x72, 0x6f, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75,
0x74, 0x65, 0x73, 0x54, 0x79, 0x70, 0x65, 0x12, 0x06, 0x0a, 0x02, 0x48, 0x70, 0x10, 0x00, 0x12,
0x07, 0x0a, 0x03, 0x41, 0x74, 0x6b, 0x10, 0x01, 0x12, 0x07, 0x0a, 0x03, 0x44, 0x65, 0x66, 0x10,
0x02, 0x12, 0x09, 0x0a, 0x05, 0x53, 0x70, 0x65, 0x65, 0x64, 0x10, 0x03, 0x12, 0x08, 0x0a, 0x04,
0x43, 0x72, 0x69, 0x74, 0x10, 0x04, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -2066,7 +2125,7 @@ func file_comm_proto_rawDescGZIP() []byte {
}
var file_comm_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_comm_proto_msgTypes = make([]protoimpl.MessageInfo, 27)
var file_comm_proto_msgTypes = make([]protoimpl.MessageInfo, 28)
var file_comm_proto_goTypes = []interface{}{
(HeroAttributesType)(0), // 0: HeroAttributesType
(*UserMessage)(nil), // 1: UserMessage
@ -2096,18 +2155,19 @@ var file_comm_proto_goTypes = []interface{}{
(*RPCGeneralReqA4)(nil), // 25: RPCGeneralReqA4
(*RPCRTaskReq)(nil), // 26: RPCRTaskReq
(*ServiceDBInfo)(nil), // 27: ServiceDBInfo
(*anypb.Any)(nil), // 28: google.protobuf.Any
(ErrorCode)(0), // 29: ErrorCode
(*ErrorData)(nil), // 28: ErrorData
(*anypb.Any)(nil), // 29: google.protobuf.Any
(ErrorCode)(0), // 30: ErrorCode
}
var file_comm_proto_depIdxs = []int32{
28, // 0: UserMessage.data:type_name -> google.protobuf.Any
28, // 1: AgentMessage.Message:type_name -> google.protobuf.Any
29, // 2: RPCMessageReply.Code:type_name -> ErrorCode
28, // 3: RPCMessageReply.ErrorData:type_name -> google.protobuf.Any
29, // 0: UserMessage.data:type_name -> google.protobuf.Any
29, // 1: AgentMessage.Message:type_name -> google.protobuf.Any
30, // 2: RPCMessageReply.Code:type_name -> ErrorCode
29, // 3: RPCMessageReply.ErrorData:type_name -> google.protobuf.Any
1, // 4: RPCMessageReply.Reply:type_name -> UserMessage
1, // 5: AgentSendMessageReq.Reply:type_name -> UserMessage
28, // 6: BatchMessageReq.Data:type_name -> google.protobuf.Any
28, // 7: BroadCastMessageReq.Data:type_name -> google.protobuf.Any
29, // 6: BatchMessageReq.Data:type_name -> google.protobuf.Any
29, // 7: BroadCastMessageReq.Data:type_name -> google.protobuf.Any
8, // [8:8] is the sub-list for method output_type
8, // [8:8] is the sub-list for method input_type
8, // [8:8] is the sub-list for extension type_name
@ -2446,6 +2506,18 @@ func file_comm_proto_init() {
return nil
}
}
file_comm_proto_msgTypes[27].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ErrorData); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
@ -2453,7 +2525,7 @@ func file_comm_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_comm_proto_rawDesc,
NumEnums: 1,
NumMessages: 27,
NumMessages: 28,
NumExtensions: 0,
NumServices: 0,
},