service/api/errs/error.go

66 lines
2.7 KiB
Go

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,
ErrVasNoEnoughWithdrawDias: errcode.ErrCodeVasNoEnoughWithdrawDias,
ErrVasAlipayUniTransferFail: errcode.ErrCodeVasAlipayUniTransferFail,
ErrVasOverTodayWithdrawCnt: errcode.ErrCodeVasOverTodayWithdrawCnt,
}
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")
ErrVasNoEnoughWithdrawDias = errors.New("no enough withdraw dias")
ErrVasAlipayUniTransferFail = errors.New("alipay uni transfer fail")
ErrVasOverTodayWithdrawCnt = errors.New("over today withdraw cnt")
)