diff --git a/internal/biz/cron_notice.go b/internal/biz/cron_notice.go index 9e29cf2..8d062a8 100644 --- a/internal/biz/cron_notice.go +++ b/internal/biz/cron_notice.go @@ -7,6 +7,7 @@ import ( "github.com/go-kratos/kratos/v2/log" "github.com/redis/go-redis/v9" "golang.org/x/sync/errgroup" + "runtime" "time" "voucher/internal/biz/bo" "voucher/internal/biz/vo" @@ -161,16 +162,17 @@ func (v *VoucherBiz) ExecuteNotice(ctx context.Context, req *bo.FindInBatchesUse func (v *VoucherBiz) notice(ctx context.Context, order *bo.OrderBo, notifyNum *int) (respErr error) { // 批量通知不做数据存储,量会很大 - defer func() { - if err := recover(); err != nil { - respErr = fmt.Errorf("panic:%v", err) - } - }() - if order == nil { return fmt.Errorf("order is nil") } + defer func() { + if err := recover(); err != nil { + _, file, line, _ := runtime.Caller(1) // 1 表示获取当前调用者的调用信息 + respErr = fmt.Errorf("notice panic:%v, orderNo:%s, file:%s, line:%d", err, order.OrderNo, file, line) + } + }() + status, err := v.WechatCpnRepo.Query(ctx, order) if err != nil { return err @@ -210,7 +212,8 @@ func (v *VoucherBiz) request(ctx context.Context, order *bo.OrderBo, notify *bo. defer func() { if err := recover(); err != nil { - respErr = fmt.Errorf("panic:%v,orderNo:%s", err, order.OrderNo) + _, file, line, _ := runtime.Caller(1) // 1 表示获取当前调用者的调用信息 + respErr = fmt.Errorf("panic:%v, orderNo:%s, file:%s, line:%d", err, order.OrderNo, file, line) } }()