xcode

package
v0.0.0-...-04961f1 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	OK                 = add(0, "OK")
	NoLogin            = add(101, "NOT_LOGIN")
	RequestErr         = add(400, "INVALID_ARGUMENT")
	Unauthorized       = add(401, "UNAUTHENTICATED")
	AccessDenied       = add(403, "PERMISSION_DENIED")
	NotFound           = add(404, "NOT_FOUND")
	MethodNotAllowed   = add(405, "METHOD_NOT_ALLOWED")
	Canceled           = add(498, "CANCELED")
	ServerErr          = add(500, "INTERNAL_ERROR")
	ServiceUnavailable = add(503, "UNAVAILABLE")
	Deadline           = add(504, "DEADLINE_EXCEEDED")
	LimitExceed        = add(509, "RESOURCE_EXHAUSTED")
)

Functions

func ErrHandler

func ErrHandler(err error) (int, any)

func FromError

func FromError(err error) *status.Status

Types

type Code

type Code struct {
	// contains filtered or unexported fields
}

func New

func New(code int, msg string) Code

func String

func String(s string) Code

func (Code) Code

func (c Code) Code() int

func (Code) Details

func (c Code) Details() []interface{}

func (Code) Error

func (c Code) Error() string

func (Code) Message

func (c Code) Message() string

type Status

type Status struct {
	// contains filtered or unexported fields
}

func Error

func Error(code Code) *Status

func Errorf

func Errorf(code Code, format string, args ...interface{}) *Status

func FromCode

func FromCode(code Code) *Status

func (*Status) Code

func (s *Status) Code() int

func (*Status) Details

func (s *Status) Details() []interface{}

func (*Status) Error

func (s *Status) Error() string

func (*Status) Message

func (s *Status) Message() string

func (*Status) Proto

func (s *Status) Proto() *types.Status

func (*Status) WithDetails

func (s *Status) WithDetails(msgs ...proto.Message) (*Status, error)

type XCode

type XCode interface {
	Error() string
	Code() int
	Message() string
	Details() []interface{}
}

func CodeFromError

func CodeFromError(err error) XCode

func FromProto

func FromProto(pbMsg proto.Message) XCode

func GrpcStatusToXCode

func GrpcStatusToXCode(gstatus *status.Status) XCode

GrpcStatusToXCode 将 gRPC的错误状态转换为自定义的错误代码 (XCode)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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