errorpb

package
v0.0.0-...-53c1a21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 17, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

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

func FromError(err error) (*Error, bool)

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

func Internalf(format string, args ...interface{}) *Error

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 MustFromError(err error) *Error

func New

func New(c codes.Code, id ...string) *Error

New creates a new Error just like grpc status

func (*Error) Descriptor deprecated

func (*Error) Descriptor() ([]byte, []int)

Deprecated: Use Error.ProtoReflect.Descriptor instead.

func (*Error) Error

func (e *Error) Error() string

func (*Error) GRPCStatus

func (e *Error) GRPCStatus() *status.Status

func (*Error) GetCode

func (x *Error) GetCode() int32

func (*Error) GetDomain

func (x *Error) GetDomain() string

func (*Error) GetId

func (x *Error) GetId() string

func (*Error) GetMessage

func (x *Error) GetMessage() string

func (*Error) GetMetadata

func (x *Error) GetMetadata() map[string]string

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) Reset

func (x *Error) Reset()

func (*Error) String

func (x *Error) String() string

func (*Error) WithCode

func (e *Error) WithCode(c codes.Code) *Error

func (*Error) WithContext

func (e *Error) WithContext(ctx context.Context) *Error

WithContext will add request id to the meta

func (*Error) WithDomain

func (e *Error) WithDomain(domain string) *Error

func (*Error) WithID

func (e *Error) WithID(id string) *Error

func (*Error) WithMessage

func (e *Error) WithMessage(msg string) *Error

func (*Error) WithMeta

func (e *Error) WithMeta(key, val string) *Error

WithMeta will add key - val to the meta

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL