service/api/errs/error.go

60 lines
2.2 KiB
Go
Raw Normal View History

2023-12-21 22:17:40 +08:00
package errs
import (
"github.com/pkg/errors"
"service/api/errcode"
)
func DealVasErr(err error) (errcode.ErrCode, error) {
var (
ec = errcode.ErrCodeVasSrvOk
ok bool
)
if err != nil {
ec, ok = ErrEcMap[err]
err = errors.Wrap(err, "VasError")
if ok {
return ec, err
}
ec = errcode.ErrCodeVasSrvFail
return ec, err
}
return ec, err
}
var ErrEcMap = map[error]errcode.ErrCode{
ErrVasProductNotExists: errcode.ErrCodeProductNotExist,
ErrVasNotMoneyProduct: errcode.ErrCodeVasNotMoneyProduct,
ErrVasWalletNotExist: errcode.ErrCodeVasWalletNotExist,
ErrVasInvalidContactProduct: errcode.ErrCodeVasInvalidContactProduct,
ErrVasUserVasNotExist: errcode.ErrCodeVasUserVasNotExist,
ErrVasNoEnoughCoin: errcode.ErrCodeVasNoEnoughCoin,
ErrVasInvalidCoinPrice: errcode.ErrCodeVasInvalidCoinPrice,
ErrVasInvalidOrder: errcode.ErrCodeVasInvalidOrder,
ErrVasOrderNotMatch: errcode.ErrCodeVasOrderNotMatch,
ErrVasOrderNotExists: errcode.ErrCodeVasOrderNotExists,
ErrVasNotUnlock: errcode.ErrCodeVasNotUnlock,
ErrVasAlreadyUnlock: errcode.ErrCodeVasAlreadyUnlock,
ErrVasRepeatDeal: errcode.ErrCodeVasRepeatDeal,
ErrVasInvalidCalcPrice: errcode.ErrCodeVasInvalidCalcPrice,
ErrVasInvalidParam: errcode.ErrCodeVasInvalidParam,
}
var (
ErrVasProductNotExists = errors.New("vas product not exists")
ErrVasNotMoneyProduct = errors.New("not money product")
ErrVasWalletNotExist = errors.New("vas wallet not exists")
ErrVasInvalidContactProduct = errors.New("invalid contact product")
ErrVasUserVasNotExist = errors.New("user vas not exists")
ErrVasNoEnoughCoin = errors.New("no enough coin")
ErrVasInvalidCoinPrice = errors.New("invalid coin price")
ErrVasInvalidOrder = errors.New("invalid order")
ErrVasOrderNotMatch = errors.New("order not match")
ErrVasOrderNotExists = errors.New("order not exists")
ErrVasNotUnlock = errors.New("not unlock")
ErrVasAlreadyUnlock = errors.New("already unlock")
ErrVasRepeatDeal = errors.New("repeat deal")
ErrVasInvalidCalcPrice = errors.New("invalid calc price")
ErrVasInvalidParam = errors.New("invalid param")
)