xerr

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrParam                  = New(ParamError, "param error")
	ErrUnauthorized           = New(UnauthorizedError, "unauthorized error")
	ErrServer                 = New(ServerError, "server error")
	ErrDB                     = New(DbError, "db error")
	ErrCaptcha                = New(CaptchaError, "captcha error")
	ErrGoogleAuthCodeRequired = New(GoogleAuthCodeRequired, "google auth code required")
)

通用错误

Functions

func New

func New(code ErrCode, msg string, args ...interface{}) error

New 创建自定义错误

func NewParamErr

func NewParamErr(msg string) error

NewParamErr ...

Types

type ErrCode

type ErrCode int

ErrCode 业务错误码

const (
	ParamError             ErrCode = 400 // 参数错误
	UnauthorizedError      ErrCode = 401 // 无权限
	ServerError            ErrCode = 500 // 服务器内部错误
	DbError                ErrCode = 600 // 数据库错误
	CaptchaError           ErrCode = 700 // 验证码错误
	GoogleAuthCodeRequired ErrCode = 701 // 需要google验证码
)

func (ErrCode) Int

func (e ErrCode) Int() int

type ErrCodeMessage

type ErrCodeMessage struct {
	Code ErrCode `json:"code"`
	Msg  string  `json:"msg"`
}

Jump to

Keyboard shortcuts

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