ecode

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Success = &Errno{Code: 1000000, Msg: "成功"}
	Error   = &Errno{Code: 2000000, Msg: "失败"}

	ClientParamLack       = &Errno{Code: 2000100, Msg: "参数缺失"}
	ClientParamTypeFail   = &Errno{Code: 2000101, Msg: "参数类型错误"}
	ClientParamValueIlleg = &Errno{Code: 2000102, Msg: "参数值非法"}
	ClientFileExtIlleg    = &Errno{Code: 2000200, Msg: "非法文件类型"}
	ClientRequestRefuse   = &Errno{Code: 2010100, Msg: "请求拒绝"}
	ClientRequestRate     = &Errno{Code: 2010200, Msg: "请求过频"}
	ClientUnknownError    = &Errno{Code: 2999999, Msg: "未知客户端异常"}

	TipsDbNull      = &Errno{Code: 4000100, Msg: "DB查询结果为空"}
	TipsRedisNull   = &Errno{Code: 4000200, Msg: "redis查询结果为空"}
	TipsEsNull      = &Errno{Code: 4000300, Msg: "es查询结果为空"}
	TipsMongodbNull = &Errno{Code: 4000400, Msg: "mongodb查询结果为空"}
	TipsUserNoLogin = &Errno{Code: 4010100, Msg: "用户未登录"}

	ErrorDbConnectFail        = &Errno{Code: 5000100, Msg: "数据库链接失败"}
	ErrorDbSqlFail            = &Errno{Code: 5000101, Msg: "数据库SQL执行语句失败"}
	ErrorDbBreakFail          = &Errno{Code: 5000102, Msg: "数据库异常退出"}
	ErrorRedisConnectFail     = &Errno{Code: 5000200, Msg: "redis链接失败"}
	ErrorRedisCheckFail       = &Errno{Code: 5000201, Msg: "redis执行语句失败"}
	ErrorMongodbConnectFail   = &Errno{Code: 5000300, Msg: "mongodb链接失败"}
	ErrorMongodbCheckFail     = &Errno{Code: 5000301, Msg: "mongodb执行语句失败"}
	ErrorEsConnectFail        = &Errno{Code: 5000400, Msg: "es链接失败"}
	ErrorEsCheckFail          = &Errno{Code: 5000401, Msg: "es执行语句失败"}
	ErrorOutApiConnectFail    = &Errno{Code: 5010100, Msg: "三方接口链接失败"}
	ErrorOutApiTimeoutFail    = &Errno{Code: 5010101, Msg: "三方接口响应超时"}
	ErrorInsideApiConnectFail = &Errno{Code: 5010200, Msg: "内部接口链接失败"}
	ErrorInsideApiTimeoutFail = &Errno{Code: 5010201, Msg: "内部接口响应超时"}
	ErrorUnknownError         = &Errno{Code: 5999999, Msg: "未知服务异常"}
)

Functions

func InitErrHook

func InitErrHook(hook ErrHandle)

InitErrHook 这个是全局的,请勿在程序中调用多次

Types

type ErrHandle

type ErrHandle func(err error)

type Errno

type Errno struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
}

Errno 基础定义错误码

func (*Errno) Error

func (e *Errno) Error() string

type ErrorX

type ErrorX struct {
	*Errno
	Ext        error  `json:"-"`
	ExtMessage string `json:"ext_msg,omitempty"`
}

func Wrap

func Wrap(errno *Errno, err error) *ErrorX

func (*ErrorX) Error

func (e *ErrorX) Error() string

Jump to

Keyboard shortcuts

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