diff --git a/internal/biz/warning_budget.go b/internal/biz/warning_budget.go index 326a3b9..fad3bba 100644 --- a/internal/biz/warning_budget.go +++ b/internal/biz/warning_budget.go @@ -6,6 +6,7 @@ import ( "fmt" "github.com/go-kratos/kratos/v2/log" "github.com/wechatpay-apiv3/wechatpay-go/services/cashcoupons" + "runtime" "strconv" "strings" "time" @@ -109,7 +110,15 @@ func (this *VoucherBiz) cronWarningBudget(ctx context.Context) error { }) } -func (this *VoucherBiz) WarningBudget(ctx context.Context, product *bo.ProductBo) error { +func (this *VoucherBiz) WarningBudget(ctx context.Context, product *bo.ProductBo) (wErr error) { + + defer func() { + if err := recover(); err != nil { + _, file, line, _ := runtime.Caller(1) // 1 表示获取当前调用者的调用信息 + log.Errorf("预警查询,发生错误:req:%s,err:%v,file:%s,line:%d", product.BatchNo, err, file, line) + wErr = fmt.Errorf("预警查询,panic: %v", err) + } + }() if product.WarningBudget == 0 { return fmt.Errorf("no warning budget")