myerr

package
v0.0.0-...-00ec2d6 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2021 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Common errors
	OK                  = &ErrNum{Code: 0, Message: "OK"}
	InternalServerError = &ErrNum{Code: 30001, Message: "内部错误."}
	ErrBind             = &ErrNum{Code: 30002, Message: "请求信息无法转换成结构体."}
	ErrDatabase         = &ErrNum{Code: 30002, Message: "Database error."}
	ErrValidation       = &ErrNum{Code: 30001, Message: "Validation failed."}
	ErrEncrypt          = &ErrNum{Code: 30101, Message: "Error occurred while encrypting the user password."}
	// user errors
	ErrAccountNotFound = &ErrNum{Code: 50102, Message: "用户不存在."}
	ErrPassword        = &ErrNum{Code: 50103, Message: "密码错误."}
	ErrAccountEmpty    = &ErrNum{Code: 50104, Message: "用户名不能为空."}
	ErrPasswordEmpty   = &ErrNum{Code: 50103, Message: "密码不能为空."}
	ErrMissingHeader   = &ErrNum{Code: 50104, Message: "Header 不存在"}
	ErrToken           = &ErrNum{Code: 50105, Message: "生成 Token 错误"}
	PassParamCheck     = &ErrNum{Code: 60000, Message: "参数校验通过"}
)

Functions

func DecodeErr

func DecodeErr(err error) (int, string)

func IsErrAccountNotFound

func IsErrAccountNotFound(err error) bool

Types

type Err

type Err struct {
	ErrNum ErrNum
	Err    error
}

func New

func New(num ErrNum, err error) *Err

func (*Err) Add

func (e *Err) Add(message string) Err

func (*Err) AddFormat

func (err *Err) AddFormat(format string, args ...interface{}) Err

func (*Err) Error

func (err *Err) Error() string

type ErrNum

type ErrNum struct {
	Code    int
	Message string
}

func (*ErrNum) Error

func (e *ErrNum) Error() string

Jump to

Keyboard shortcuts

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