errs

package
v0.0.0-...-c2b9a33 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: Apache-2.0 Imports: 3 Imported by: 5

Documentation

Index

Constants

View Source
const (
	FormattingError      = 10001
	HasRegistered        = 10002
	NotRegistered        = 10003
	PasswordErr          = 10004
	GetIMTokenErr        = 10005
	RepeatSendCode       = 10006
	MailSendCodeErr      = 10007
	SmsSendCodeErr       = 10008
	CodeInvalidOrExpired = 10009
	RegisterFailed       = 10010
	ResetPasswordFailed  = 10011
	RegisterLimit        = 10012
	LoginLimit           = 10013
	InvitationError      = 10014
)
View Source
const (
	NoError       = 0     // 无错误
	DatabaseError = 90002 // redis/mysql等db错误
	NetworkError  = 90004 // 网络错误
	DataError     = 90007 // 数据错误

	CallbackError = 80000

	// 通用错误码.
	ServerInternalError = 500  // 服务器内部错误
	ArgsError           = 1001 // 输入参数错误
	NoPermissionError   = 1002 // 权限不足
	DuplicateKeyError   = 1003
	RecordNotFoundError = 1004 // 记录不存在

	// 账号错误码.
	UserIDNotFoundError    = 1101 // UserID不存在 或未注册
	RegisteredAlreadyError = 1102 // 用户已经注册过了

	// 群组错误码.
	GroupIDNotFoundError  = 1201 // GroupID不存在
	GroupIDExisted        = 1202 // GroupID已存在
	NotInGroupYetError    = 1203 // 不在群组中
	DismissedAlreadyError = 1204 // 群组已经解散
	GroupTypeNotSupport   = 1205
	GroupRequestHandled   = 1206

	// 关系链错误码.
	CanNotAddYourselfError   = 1301 // 不能添加自己为好友
	BlockedByPeer            = 1302 // 被对方拉黑
	NotPeersFriend           = 1303 // 不是对方的好友
	RelationshipAlreadyError = 1304 // 已经是好友关系

	// 消息错误码.
	MessageHasReadDisable = 1401
	MutedInGroup          = 1402 // 群成员被禁言
	MutedGroup            = 1403 // 群被禁言
	MsgAlreadyRevoke      = 1404 // 消息已撤回

	// token错误码.
	TokenExpiredError     = 1501
	TokenInvalidError     = 1502
	TokenMalformedError   = 1503
	TokenNotValidYetError = 1504
	TokenUnknownError     = 1505
	TokenKickedError      = 1506
	TokenNotExistError    = 1507

	// 长连接网关错误码.
	ConnOverMaxNumLimit = 1601
	ConnArgsErr         = 1602

	// S3错误码.
	FileUploadedExpiredError = 1701 // 上传过期
)

通用错误码.

View Source
const UnknownCode = 1000

UnknownCode 没有解析到code或解析的code=0.

Variables

View Source
var (
	ErrArgs             = NewCodeError(ArgsError, "ArgsError")
	ErrNoPermission     = NewCodeError(NoPermissionError, "NoPermissionError")
	ErrDatabase         = NewCodeError(DatabaseError, "DatabaseError")
	ErrInternalServer   = NewCodeError(ServerInternalError, "ServerInternalError")
	ErrNetwork          = NewCodeError(NetworkError, "NetworkError")
	ErrCallback         = NewCodeError(CallbackError, "CallbackError")
	ErrCallbackContinue = NewCodeError(CallbackError, "ErrCallbackContinue")

	ErrUserIDNotFound  = NewCodeError(UserIDNotFoundError, "UserIDNotFoundError")
	ErrGroupIDNotFound = NewCodeError(GroupIDNotFoundError, "GroupIDNotFoundError")
	ErrGroupIDExisted  = NewCodeError(GroupIDExisted, "GroupIDExisted")

	ErrRecordNotFound = NewCodeError(RecordNotFoundError, "RecordNotFoundError")

	ErrNotInGroupYet       = NewCodeError(NotInGroupYetError, "NotInGroupYetError")
	ErrDismissedAlready    = NewCodeError(DismissedAlreadyError, "DismissedAlreadyError")
	ErrRegisteredAlready   = NewCodeError(RegisteredAlreadyError, "RegisteredAlreadyError")
	ErrGroupTypeNotSupport = NewCodeError(GroupTypeNotSupport, "")
	ErrGroupRequestHandled = NewCodeError(GroupRequestHandled, "GroupRequestHandled")

	ErrData             = NewCodeError(DataError, "DataError")
	ErrTokenExpired     = NewCodeError(TokenExpiredError, "TokenExpiredError")
	ErrTokenInvalid     = NewCodeError(TokenInvalidError, "TokenInvalidError")         //
	ErrTokenMalformed   = NewCodeError(TokenMalformedError, "TokenMalformedError")     // 格式错误
	ErrTokenNotValidYet = NewCodeError(TokenNotValidYetError, "TokenNotValidYetError") // 还未生效
	ErrTokenUnknown     = NewCodeError(TokenUnknownError, "TokenUnknownError")         // 未知错误
	ErrTokenKicked      = NewCodeError(TokenKickedError, "TokenKickedError")
	ErrTokenNotExist    = NewCodeError(TokenNotExistError, "TokenNotExistError") // 在redis中不存在
	ErrDuplicateKey     = NewCodeError(DuplicateKeyError, "DuplicateKeyError")

	ErrMessageHasReadDisable = NewCodeError(MessageHasReadDisable, "MessageHasReadDisable")

	ErrCanNotAddYourself   = NewCodeError(CanNotAddYourselfError, "CanNotAddYourselfError")
	ErrBlockedByPeer       = NewCodeError(BlockedByPeer, "BlockedByPeer")
	ErrNotPeersFriend      = NewCodeError(NotPeersFriend, "NotPeersFriend")
	ErrRelationshipAlready = NewCodeError(RelationshipAlreadyError, "RelationshipAlreadyError")

	ErrMutedInGroup     = NewCodeError(MutedInGroup, "MutedInGroup")
	ErrMutedGroup       = NewCodeError(MutedGroup, "MutedGroup")
	ErrMsgAlreadyRevoke = NewCodeError(MsgAlreadyRevoke, "MsgAlreadyRevoke")

	ErrConnOverMaxNumLimit = NewCodeError(ConnOverMaxNumLimit, "ConnOverMaxNumLimit")

	ErrConnArgsErr = NewCodeError(ConnArgsErr, "args err, need token, sendID, platformID")

	ErrFileUploadedExpired = NewCodeError(FileUploadedExpiredError, "FileUploadedExpiredError")
)
View Source
var Relation = &relation{m: make(map[int]map[int]struct{})}

Functions

func Unwrap

func Unwrap(err error) error

func Wrap

func Wrap(err error, msg ...string) error

Types

type CodeError

type CodeError interface {
	Code() int
	Msg() string
	Detail() string
	WithDetail(detail string) CodeError
	// Is 判断是否是某个错误, loose为false时, 只有错误码相同就认为是同一个错误, 默认为true
	Is(err error, loose ...bool) bool
	Wrap(msg ...string) error
	error
}

func NewCodeError

func NewCodeError(code int, msg string) CodeError

Jump to

Keyboard shortcuts

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