diff --git a/server/util/check.go b/server/util/check.go index 11f8610d4902bcd9297475ec021a257f4b33af36..643845b104dc866a152de49a3a5fd57626f462a9 100644 --- a/server/util/check.go +++ b/server/util/check.go @@ -26,6 +26,14 @@ func (cu checkUtil) CheckErr(err error, template string, args ...interface{}) { } } +// CheckApiErr 抛出自定义具体错误到API +func (cu checkUtil) CheckApiErr(err error, msg string) { + if err != nil { + core.Logger.WithOptions(zap.AddCallerSkip(1)).Errorf("err=[%+v]", err) + panic(response.ThrowExcption.Make(msg)) + } +} + //CheckErrDBNotRecord 校验数据库记录不存在的错误 func (cu checkUtil) CheckErrDBNotRecord(err error, msg string) { if err != nil && errors.Is(err, gorm.ErrRecordNotFound) {