state

package
v0.0.0-...-7cf99fd Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoResult = "mongo: no documents in result"
)

Variables

View Source
var (
	Success                   = NewError(0, "成功")
	ServerError               = NewError(10000, "服务内部错误")
	InvalidParams             = NewError(10001, "传入参数错误")
	NotFound                  = NewError(10002, "未找到对应的资源")
	UnauthorizedAuthNotExist  = NewError(10003, "鉴权失败,未找到对应的 AppKey 和 AppSecret")
	UnauthorizedTokenError    = NewError(10004, "鉴权失败,Token 错误")
	UnauthorizedTokenTimeout  = NewError(10005, "鉴权失败,Token 超时")
	UnauthorizedTokenGenerate = NewError(10006, "鉴权失败,Token 生成失败")
	TooManyRequests           = NewError(10007, "请求过多")
	DatabaseError             = NewError(10008, "数据库处理错误")
	RedisError                = NewError(10009, "缓存处理错误")

	IDIllegal       = NewError(20000, "非法的编号")
	UsernameExisted = NewError(20001, "用户名已存在")
	MobileExisted   = NewError(20002, "手机号已存在")
	EmailExisted    = NewError(20003, "邮箱已存在")
	LoginError      = NewError(20004, "账号/密码错误")
	SMSError        = NewError(20005, "短信发送失败")
)

Functions

This section is empty.

Types

type Error

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

状态错误

func NewError

func NewError(code int32, msg string) *Error

func TransMongodbError

func TransMongodbError(err error) *Error

func (*Error) Code

func (e *Error) Code() int32

func (*Error) Error

func (e *Error) Error() string

func (*Error) Message

func (e *Error) Message(args ...interface{}) string

func (*Error) Response

func (e *Error) Response(args ...interface{}) *ErrorResponse

func (*Error) StatusCode

func (e *Error) StatusCode() int

type ErrorResponse

type ErrorResponse struct {
	Code    int32  `json:"code"`
	Message string `json:"msg"`
}

type Platform

type Platform int32
const (
	Web     Platform = 1 // 浏览器
	Mobile  Platform = 2 // 移动端
	Desktop Platform = 3 // 桌面端
)

func GetPlatform

func GetPlatform(ctx context.Context) Platform

func (Platform) String

func (p Platform) String() string

type ValidError

type ValidError struct {
	Key     string
	Message string
}

请求验证错误

func (*ValidError) Error

func (v *ValidError) Error() string

type ValidErrors

type ValidErrors []*ValidError

func (ValidErrors) Error

func (v ValidErrors) Error() string

Jump to

Keyboard shortcuts

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