ecode

package
v1.5.20 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// base error
	OK             = New(1, "success")
	RequestErr     = New(20000, "网关校验缺少参数。")
	UserIDErr      = New(30000, "用户身份验证失败。")
	DevIDErr       = New(30001, "开发者身份验证失败。")
	SignErr        = New(40000, "签名验证失败。")
	ServerErr      = New(50000, "服务异常。")
	GatewayErr     = New(50001, "网关异常。")
	ConfigParamErr = New(-1, "config missing parameter")
)

Functions

This section is empty.

Types

type Codes

type Codes interface {
	// sometimes Error return Code in string form
	Error() string
	// Code get error code.
	Code() int
	// Message get code message.
	Message() string
}

Codes ecode error interface which has a code & message.

func AnalyseError

func AnalyseError(err error) Codes

analyse error info

type Error

type Error int

A Code is an int error code spec.

func Add

func Add(code int) Error

Add init you self service error code

func New

func New(code int, msg string) Error

New new error code and msg

func (Error) Code

func (e Error) Code() int

Code return error code

func (Error) Error

func (e Error) Error() string

func (Error) GRPCStatus added in v1.5.11

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

func (Error) Message

func (e Error) Message() string

Message return error message

Jump to

Keyboard shortcuts

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