Documentation ¶
Index ¶
- Constants
- Variables
- func ErrorParser(err error) (zapcore.ObjectMarshaler, bool)
- func GrpcGWErrorHandler() runtime.ServeMuxOption
- func GrpcGWRoutingErrorHandler() runtime.ServeMuxOption
- type Error
- func (*Error) Descriptor() ([]byte, []int)deprecated
- func (e *Error) Error() string
- func (e *Error) GRPCStatus() *status.Status
- func (x *Error) GetCode() int32
- func (x *Error) GetDomain() string
- func (x *Error) GetId() string
- func (x *Error) GetMessage() string
- func (x *Error) GetMetadata() map[string]string
- func (e *Error) MarshalLogObject(enc zapcore.ObjectEncoder) error
- func (*Error) ProtoMessage()
- func (x *Error) ProtoReflect() protoreflect.Message
- func (x *Error) Reset()
- func (x *Error) String() string
- func (e *Error) WithCode(c codes.Code) *Error
- func (e *Error) WithContext(ctx context.Context) *Error
- func (e *Error) WithDomain(domain string) *Error
- func (e *Error) WithID(id string) *Error
- func (e *Error) WithMessage(msg string) *Error
- func (e *Error) WithMeta(key, val string) *Error
Constants ¶
View Source
const ( KeyInvalidArg = "ARG" KeyRequestID = "REQUEST_ID" KeyInfoField = "FORM_FIELD" KeyStack = "STACK" )
Variables ¶
View Source
var File_errorpb_proto protoreflect.FileDescriptor
Functions ¶
func ErrorParser ¶
func ErrorParser(err error) (zapcore.ObjectMarshaler, bool)
func GrpcGWErrorHandler ¶
func GrpcGWErrorHandler() runtime.ServeMuxOption
func GrpcGWRoutingErrorHandler ¶
func GrpcGWRoutingErrorHandler() runtime.ServeMuxOption
Types ¶
type Error ¶
type Error struct { // grpc code. Code int32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"` // Error ID. Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"` // domain that generated the error. Domain string `protobuf:"bytes,3,opt,name=domain,proto3" json:"domain,omitempty"` // Human-readable message. Message string `protobuf:"bytes,4,opt,name=message,proto3" json:"message,omitempty"` // Other metadata. Metadata map[string]string `` /* 157-byte string literal not displayed */ // contains filtered or unexported fields }
func FromError ¶
FromError like status.FromError, it tries to convert grpc error into gdserror. If err implements the method `GDSStatus() *Error`, it will be returned directly. Additionall, context error, validation error, io.EOF, net.OpErr will be parsed into Error. If it is a vanilla grpc error, UNKNOWN_GRPC id and the original error message will be embeded. Otherwise, ok is false and it will embeds the err to Error
func Internalf ¶
Internalf log the message then wrap it with InternalErr Stack dump and line number will be recorded in meta STACK and FILE
func MustFromError ¶
func (*Error) Descriptor
deprecated
func (*Error) GRPCStatus ¶
func (*Error) GetMessage ¶
func (*Error) GetMetadata ¶
func (*Error) MarshalLogObject ¶
func (e *Error) MarshalLogObject(enc zapcore.ObjectEncoder) error
MarshalLogObject implements zap.ObjectMarshaler
func (*Error) ProtoMessage ¶
func (*Error) ProtoMessage()
func (*Error) ProtoReflect ¶
func (x *Error) ProtoReflect() protoreflect.Message
func (*Error) WithContext ¶
WithContext will add request id to the meta
func (*Error) WithDomain ¶
func (*Error) WithMessage ¶
Click to show internal directories.
Click to hide internal directories.