errcode

package
v0.0.0-...-7230577 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Success          = NewError(0, "成功")
	ServerError      = NewError(10000000, "内部错误")
	InvalidParams    = NewError(10000001, "无效参数")
	Unauthorized     = NewError(10000002, "认证错误")
	NotFound         = NewError(10000003, "没有找到")
	Unknown          = NewError(10000004, "未知")
	DeadlineExceeded = NewError(10000005, "超出最后截止期限")
	AccessDenied     = NewError(10000006, "访问被拒绝")
	LimitExceed      = NewError(10000007, "访问限制")
	TooManyRequests  = NewError(10000008, "请求过多")
	MethodNotAllowed = NewError(10000009, "不支持该方法")
)

Functions

func ToRPCCode

func ToRPCCode(code int) codes.Code

func TogRPCError

func TogRPCError(err *Error) error

Types

type Error

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

func NewError

func NewError(code int, msg string) *Error

func (*Error) Code

func (e *Error) Code() int

func (*Error) Details

func (e *Error) Details() []string

func (*Error) Error

func (e *Error) Error() string

func (*Error) Msg

func (e *Error) Msg() string

func (*Error) Msgf

func (e *Error) Msgf(args []interface{}) string

func (*Error) StatusCode

func (e *Error) StatusCode() int

func (*Error) WithDetails

func (e *Error) WithDetails(details ...string) *Error

type Status

type Status struct {
	*status.Status
}

func FromError

func FromError(err error) *Status

func ToRPCStatus

func ToRPCStatus(code int, msg string) *Status

Jump to

Keyboard shortcuts

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