errCode

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// 根据https://httpstatuses.com/定义
	// 小于1000的是系统内置的报错信息,业务代码也可以使用,但是Equal()比较时候只会比较code码,不会严格比较错误信息
	OK                   = New(200, "200 OK")
	BadRequest           = New(400, "400 Bad Request")
	Unauthorized         = New(401, "401 Unauthorized")
	Forbidden            = New(403, "403 Forbidden")
	NotFound             = New(404, "404 Not Found")
	PreconditionRequired = New(428, "428 Precondition Required")
	LimitExceed          = New(429, "429 Too Many Requests")
	ServerClosed         = New(444, "444 Server Closed")
	ClientClosed         = New(499, "499 Client Closed")
	Internal             = New(500, "500 Internal Server Error")
	NotImplemented       = New(501, "501 Not Implemented")
	ServiceUnavailable   = New(503, "503 Service Unavailable")
	Deadline             = New(504, "504 Timeout")

	// CustomErr 1000为系统报错和业务报错分界点
	// 大于或等于1000的是业务自定义错误,当使用Equal()比较时会严格比较具体报错信息
	CustomErr = New(1000, "1000 CustomErr")
)

Functions

This section is empty.

Types

type ErrCode

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

func New

func New(code int, format string, a ...interface{}) ErrCode

func (ErrCode) Code

func (ec ErrCode) Code() int

func (ErrCode) Details

func (ec ErrCode) Details() []*anypb.Any

func (ErrCode) Equal

func (ec ErrCode) Equal(err error) bool

func (ErrCode) Error

func (ec ErrCode) Error() string

func (ErrCode) MarshalJSON

func (ec ErrCode) MarshalJSON() ([]byte, error)

func (*ErrCode) UnmarshalJSON

func (ec *ErrCode) UnmarshalJSON(b []byte) error

func (*ErrCode) WithDetails

func (ec *ErrCode) WithDetails(details ...*anypb.Any)

Jump to

Keyboard shortcuts

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