errs

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// UserNotFoundCodeCode  用户不存在
	UserNotFoundCode = AccountCodeInit + iota + 1
	// AmountInsufficientCode 用户余额不足
	AmountInsufficientCode
	// TokenValidateFailedCode token验证失败
	TokenValidateFailedCode
	// TokenExpireCode Token到期
	TokenExpireCode
	// LoginFailedCode 登录账户密码验证失败
	LoginFailedCode
)
View Source
const (
	InternalCode = CommonCodeInit + iota + 1
	RedisErrCode
	ExecSqlFailedCode
	ParamValidateFailedCode
	RecordNotFoundErrCode
	DuplicateDataErrCode
	MongoErrCode
	KafkaErrCode
	EtcdErrCode
	DtmErrCode
	PulsarErrCode
)
View Source
const (
	DefaultLanguage = "zh-CN"
	DefaultCode     = InternalCode
	EtcdPrefixKey   = "language/"
)
View Source
const (
	// PasswordNotMatchCode  密码不匹配
	PasswordNotMatchCode = AdminCodeInit + iota + 1 //密码不匹配
)

Variables

View Source
var (
	UserNotFound        = UserNotFoundCode.Error("")
	AmountInsufficient  = AmountInsufficientCode.Error("")
	TokenValidateFailed = TokenValidateFailedCode.Error("")
	TokenExpire         = TokenExpireCode.Error("")
	LoginFailed         = LoginFailedCode.Error("")
)
View Source
var (
	Internal            = InternalCode.Error("")
	RedisErr            = RedisErrCode.Error("")
	ExecSqlFailed       = ExecSqlFailedCode.Error("")
	ParamValidateFailed = ParamValidateFailedCode.Error("")
	RecordNotFoundErr   = RecordNotFoundErrCode.Error("")
	DuplicateDataErr    = DuplicateDataErrCode.Error("")
	MongoErr            = MongoErrCode.Error("")
	KafkaErr            = KafkaErrCode.Error("")
	EtcdErr             = EtcdErrCode.Error("")
	DtmErr              = DtmErrCode.Error("")
	PulsarErr           = PulsarErrCode.Error("")
)
View Source
var (
	OrderNotFound       = OrderNotFoundCode.Error("")
	OrderHasResolved    = OrderHasResolvedCode.Error("")
	LoOrderCancelFailed = LoOrderCancelFailedCode.Error("")
	NotBids             = NotBidsCode.Error("")
	NotAsks             = NotAsksCode.Error("")
	ErrPrec             = ErrPrecCode.Error("")
)
View Source
var PasswordNotMatch = PasswordNotMatchCode.Error("")

Functions

func CastToDtmError

func CastToDtmError(err error) error

CastToDtmError dtm规定 saga失败如果要补偿的话grpc返回abort 其他错误则为重试 我们的错误只能在msg中体现 refer https://dtm.pub/practice/workflow.html#%E5%88%86%E6%94%AF%E6%93%8D%E4%BD%9C%E7%BB%93%E6%9E%9C

func InitTranslator

func InitTranslator(path string)

func InitTranslatorFromEtcd

func InitTranslatorFromEtcd(etcdConfig etcd.EtcdConfig)

func WarpMessage

func WarpMessage(err error, msg string) error

Types

type Code

type Code codes.Code
const (
	CommonCodeInit Code = 100000 * (iota + 1)
	AccountCodeInit
	AdminCodeInit
	MatchCodeInit
	OrderCodeInit
	QuoteCodeInit
)
const (

	// OrderNotFoundCode 订单为未找到
	OrderNotFoundCode Code = OrderCodeInit + iota + 1
	// OrderHasResolvedCode 订单已经成交或已经取消
	OrderHasResolvedCode
	// LoOrderCancelFailedCode 市价单不允许手动取消
	LoOrderCancelFailedCode
	// NotBidsCode 订单簿没有买单
	NotBidsCode
	// NotAsksCode 订单簿没有卖单
	NotAsksCode

	ErrPrecCode
)

func (Code) DtmErrorMsg

func (c Code) DtmErrorMsg() string

func (Code) Error

func (c Code) Error(msg string) error

func (Code) String

func (c Code) String() string

func (Code) Translate

func (c Code) Translate(lang string) string

type Translator

type Translator struct {
	Codes *sync.Map
}

Jump to

Keyboard shortcuts

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