generated from pkg/go-template
feat: murder项目整体迁移
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package error_process
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
var (
|
||||
dbNotFoundErr = errors.New("db初始化失败,未从map中获取相应db")
|
||||
numNotMatchErr = errors.New("数量匹配失败")
|
||||
emptyValueErr = errors.New("空值错误")
|
||||
extraValueErr = errors.New("额外值错误")
|
||||
)
|
||||
|
||||
const (
|
||||
// BodyParserErr body 解析错误
|
||||
BodyParserErr = "BodyParserErr"
|
||||
ServiceErr = "调用service时错误"
|
||||
EtcReadError = "etcdReaderErr"
|
||||
EtcConnError = "etcConnectError"
|
||||
PanicError = "panicError"
|
||||
GormError = "gormErr"
|
||||
NoPointError = "不是指针类型"
|
||||
NilPointError = "解析失败"
|
||||
IllegalValueError = "非法值错误"
|
||||
GrammerError = "语法错误"
|
||||
)
|
||||
|
||||
func DbNotFoundErr(dbKey string) error {
|
||||
return errors.Wrap(dbNotFoundErr, fmt.Sprintf("根据dbKey:%v没有找到db记录", dbKey))
|
||||
}
|
||||
func UpdateErr(body interface{}, condition interface{}) error {
|
||||
return errors.Wrap(numNotMatchErr, fmt.Sprintf("update操作失败,条件为:%v,updateBody:%v", condition, body))
|
||||
}
|
||||
func CreateErr(err error, body interface{}) error {
|
||||
return errors.Wrap(err, fmt.Sprintf("新增失败,createBody:%v", body))
|
||||
}
|
||||
func GetErr(err error, condition interface{}) error {
|
||||
return errors.Wrap(err, fmt.Sprintf("查询失败,queryMap:%v", condition))
|
||||
}
|
||||
func RecordNotMatchWithUniqueErr(condition interface{}, expected, actual int) error {
|
||||
return errors.WithMessage(numNotMatchErr, fmt.Sprintf("查询条件:%v,期望数量:%v,实际数量:%v", condition, expected, actual))
|
||||
}
|
||||
func EmptyValueErr(key string) error {
|
||||
return errors.WithMessage(emptyValueErr, fmt.Sprintf("空值key:%v", key))
|
||||
}
|
||||
func CommonErr(err error) error {
|
||||
return errors.Wrap(err, "")
|
||||
}
|
||||
func ExtraValueErr(key string) error {
|
||||
return errors.WithMessage(extraValueErr, fmt.Sprintf("key:%v只能为空值", key))
|
||||
}
|
||||
Reference in New Issue
Block a user