From 3a32575bab61f0b7c0744b0713744bb0b9722be8 Mon Sep 17 00:00:00 2001 From: ziming Date: Wed, 18 Jun 2025 10:36:13 +0800 Subject: [PATCH] =?UTF-8?q?log=20=E5=A2=9E=E5=8A=A0=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E5=BD=93=E5=89=8D=E8=B0=83=E7=94=A8=E8=80=85=E7=9A=84=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/biz/cron_notice.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) 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) } }()