codes

package
v2.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: MIT Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	OK               = NewCode(0, "ok")
	Canceled         = NewCode(1, "canceled")
	Unknown          = NewCode(2, "unknown")
	InvalidArgument  = NewCode(3, "invalid argument")
	DeadlineExceeded = NewCode(4, "deadline exceeded")
	NotFound         = NewCode(5, "not found")
	InternalError    = NewCode(6, "internal error")
	Unauthorized     = NewCode(7, "unauthorized")
	IllegalInvoke    = NewCode(8, "illegal invoke")
	IllegalRequest   = NewCode(9, "illegal request")
)

Functions

This section is empty.

Types

type Code

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

func Convert

func Convert(err error) *Code

Convert 将错误信息转换为错误码

func NewCode

func NewCode(code int, message string) *Code

func (*Code) Code

func (c *Code) Code() int

Code 返回错误码

func (*Code) Err

func (c *Code) Err() error

Err 转错误消息

func (*Code) Format

func (c *Code) Format(s fmt.State, verb rune)

Format 格式化输出 %s : 打印错误码和错误消息 %v : 打印错误码、错误消息、错误详情

func (*Code) Message

func (c *Code) Message() string

Message 返回错误码消息

func (*Code) String

func (c *Code) String() string

String 格式化错误码

func (*Code) WithCode added in v2.1.0

func (c *Code) WithCode(code int) *Code

WithCode 替换新的错误码

func (*Code) WithMessage added in v2.1.0

func (c *Code) WithMessage(message string) *Code

WithMessage 替换新的错误码消息

type Error

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

func (*Error) Error

func (e *Error) Error() string

Error error interface implementation

Jump to

Keyboard shortcuts

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