// Code generated by thriftgo (0.2.1). DO NOT EDIT. package exceptionsc import ( "context" "fmt" "github.com/apache/thrift/lib/go/thrift" "github.com/cloudwego/thriftgo/generator/golang/extension/meta" "github.com/cloudwego/thriftgo/generator/golang/extension/unknown" ) type CommonException struct { Code int32 `thrift:"code,1" frugal:"1,default,i32" db:"code" json:"code"` Message string `thrift:"message,2" frugal:"2,default,string" db:"message" json:"message"` Metadata map[string]string `thrift:"metadata,3,optional" frugal:"3,optional,map" db:"metadata" json:"metadata,omitempty"` _unknownFields unknown.Fields } func init() { meta.RegisterStruct(NewCommonException, []byte{ 0xb, 0x0, 0x1, 0x0, 0x0, 0x0, 0xf, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x45, 0x78, 0x63, 0x65, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0xb, 0x0, 0x2, 0x0, 0x0, 0x0, 0x9, 0x65, 0x78, 0x63, 0x65, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0xf, 0x0, 0x3, 0xc, 0x0, 0x0, 0x0, 0x3, 0x6, 0x0, 0x1, 0x0, 0x1, 0xb, 0x0, 0x2, 0x0, 0x0, 0x0, 0x4, 0x63, 0x6f, 0x64, 0x65, 0x8, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0xc, 0x0, 0x4, 0x8, 0x0, 0x1, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x6, 0x0, 0x1, 0x0, 0x2, 0xb, 0x0, 0x2, 0x0, 0x0, 0x0, 0x7, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x8, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0xc, 0x0, 0x4, 0x8, 0x0, 0x1, 0x0, 0x0, 0x0, 0xb, 0x0, 0x0, 0x6, 0x0, 0x1, 0x0, 0x3, 0xb, 0x0, 0x2, 0x0, 0x0, 0x0, 0x8, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x8, 0x0, 0x3, 0x0, 0x0, 0x0, 0x2, 0xc, 0x0, 0x4, 0x8, 0x0, 0x1, 0x0, 0x0, 0x0, 0xd, 0xc, 0x0, 0x2, 0x8, 0x0, 0x1, 0x0, 0x0, 0x0, 0xb, 0x0, 0xc, 0x0, 0x3, 0x8, 0x0, 0x1, 0x0, 0x0, 0x0, 0xb, 0x0, 0x0, 0x0, 0x0, }) } func NewCommonException() *CommonException { return &CommonException{} } func (p *CommonException) InitDefault() { *p = CommonException{} } func (p *CommonException) GetCode() (v int32) { return p.Code } func (p *CommonException) GetMessage() (v string) { return p.Message } var CommonException_Metadata_DEFAULT map[string]string func (p *CommonException) GetMetadata() (v map[string]string) { if !p.IsSetMetadata() { return CommonException_Metadata_DEFAULT } return p.Metadata } func (p *CommonException) SetCode(val int32) { p.Code = val } func (p *CommonException) SetMessage(val string) { p.Message = val } func (p *CommonException) SetMetadata(val map[string]string) { p.Metadata = val } func (p *CommonException) CarryingUnknownFields() bool { return len(p._unknownFields) > 0 } var fieldIDToName_CommonException = map[int16]string{ 1: "code", 2: "message", 3: "metadata", } func (p *CommonException) IsSetMetadata() bool { return p.Metadata != nil } func (p *CommonException) Read(ctx context.Context, iprot thrift.TProtocol) (err error) { var name string var fieldTypeId thrift.TType var fieldId int16 if _, err = iprot.ReadStructBegin(ctx); err != nil { goto ReadStructBeginError } for { name, fieldTypeId, fieldId, err = iprot.ReadFieldBegin(ctx) if err != nil { goto ReadFieldBeginError } if fieldTypeId == thrift.STOP { break } switch fieldId { case 1: if fieldTypeId == thrift.I32 { if err = p.ReadField1(ctx, iprot); err != nil { goto ReadFieldError } } else { if err = iprot.Skip(ctx, fieldTypeId); err != nil { goto SkipFieldError } } case 2: if fieldTypeId == thrift.STRING { if err = p.ReadField2(ctx, iprot); err != nil { goto ReadFieldError } } else { if err = iprot.Skip(ctx, fieldTypeId); err != nil { goto SkipFieldError } } case 3: if fieldTypeId == thrift.MAP { if err = p.ReadField3(ctx, iprot); err != nil { goto ReadFieldError } } else { if err = iprot.Skip(ctx, fieldTypeId); err != nil { goto SkipFieldError } } default: if err = p._unknownFields.Append(ctx, iprot, name, fieldTypeId, fieldId); err != nil { goto UnknownFieldsAppendError } } if err = iprot.ReadFieldEnd(ctx); err != nil { goto ReadFieldEndError } } if err = iprot.ReadStructEnd(ctx); err != nil { goto ReadStructEndError } return nil ReadStructBeginError: return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) ReadFieldBeginError: return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) ReadFieldError: return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_CommonException[fieldId]), err) SkipFieldError: return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) UnknownFieldsAppendError: return thrift.PrependError(fmt.Sprintf("%T append unknown field(name:%s type:%d id:%d) error: ", p, name, fieldTypeId, fieldId), err) ReadFieldEndError: return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) ReadStructEndError: return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) } func (p *CommonException) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { if v, err := iprot.ReadI32(ctx); err != nil { return err } else { p.Code = v } return nil } func (p *CommonException) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { if v, err := iprot.ReadString(ctx); err != nil { return err } else { p.Message = v } return nil } func (p *CommonException) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { _, _, size, err := iprot.ReadMapBegin(ctx) if err != nil { return err } p.Metadata = make(map[string]string, size) for i := 0; i < size; i++ { var _key string if v, err := iprot.ReadString(ctx); err != nil { return err } else { _key = v } var _val string if v, err := iprot.ReadString(ctx); err != nil { return err } else { _val = v } p.Metadata[_key] = _val } if err := iprot.ReadMapEnd(ctx); err != nil { return err } return nil } func (p *CommonException) Write(ctx context.Context, oprot thrift.TProtocol) (err error) { var fieldId int16 if err = oprot.WriteStructBegin(ctx, "CommonException"); err != nil { goto WriteStructBeginError } if p != nil { if err = p.writeField1(ctx, oprot); err != nil { fieldId = 1 goto WriteFieldError } if err = p.writeField2(ctx, oprot); err != nil { fieldId = 2 goto WriteFieldError } if err = p.writeField3(ctx, oprot); err != nil { fieldId = 3 goto WriteFieldError } if err = p._unknownFields.Write(ctx, oprot); err != nil { goto UnknownFieldsWriteError } } if err = oprot.WriteFieldStop(ctx); err != nil { goto WriteFieldStopError } if err = oprot.WriteStructEnd(ctx); err != nil { goto WriteStructEndError } return nil WriteStructBeginError: return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) WriteFieldError: return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) WriteFieldStopError: return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) WriteStructEndError: return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) UnknownFieldsWriteError: return thrift.PrependError(fmt.Sprintf("%T write unknown fields error: ", p), err) } func (p *CommonException) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { if err = oprot.WriteFieldBegin(ctx, "code", thrift.I32, 1); err != nil { goto WriteFieldBeginError } if err := oprot.WriteI32(ctx, p.Code); err != nil { return err } if err = oprot.WriteFieldEnd(ctx); err != nil { goto WriteFieldEndError } return nil WriteFieldBeginError: return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err) WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err) } func (p *CommonException) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { if err = oprot.WriteFieldBegin(ctx, "message", thrift.STRING, 2); err != nil { goto WriteFieldBeginError } if err := oprot.WriteString(ctx, p.Message); err != nil { return err } if err = oprot.WriteFieldEnd(ctx); err != nil { goto WriteFieldEndError } return nil WriteFieldBeginError: return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err) WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err) } func (p *CommonException) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { if p.IsSetMetadata() { if err = oprot.WriteFieldBegin(ctx, "metadata", thrift.MAP, 3); err != nil { goto WriteFieldBeginError } if err := oprot.WriteMapBegin(ctx, thrift.STRING, thrift.STRING, len(p.Metadata)); err != nil { return err } for k, v := range p.Metadata { if err := oprot.WriteString(ctx, k); err != nil { return err } if err := oprot.WriteString(ctx, v); err != nil { return err } } if err := oprot.WriteMapEnd(ctx); err != nil { return err } if err = oprot.WriteFieldEnd(ctx); err != nil { goto WriteFieldEndError } } return nil WriteFieldBeginError: return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err) WriteFieldEndError: return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err) } func (p *CommonException) String() string { if p == nil { return "" } return fmt.Sprintf("CommonException(%+v)", *p) } func (p *CommonException) Error() string { return p.String() }