From bdc2af3514bdeeef559ff69e585b75933d3c7726 Mon Sep 17 00:00:00 2001 From: tikkhun Date: Thu, 8 Jan 2026 16:08:41 +0800 Subject: [PATCH] =?UTF-8?q?fix(sync=5Fshipment):=20=E6=8D=95=E8=8E=B7?= =?UTF-8?q?=E8=BF=90=E5=8D=95=E7=8A=B6=E6=80=81=E6=9B=B4=E6=96=B0=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E5=BC=82=E5=B8=B8=E5=B9=B6=E8=AE=B0=E5=BD=95=E6=97=A5?= =?UTF-8?q?=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加try-catch块来捕获updateShipmentState过程中可能出现的错误 使用logger记录错误信息以便后续排查 --- src/job/sync_shipment.job.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/job/sync_shipment.job.ts b/src/job/sync_shipment.job.ts index c532844..94707d9 100644 --- a/src/job/sync_shipment.job.ts +++ b/src/job/sync_shipment.job.ts @@ -75,10 +75,14 @@ export class SyncUniuniShipmentJob implements IJob{ '255': 'Gateway_To_Gateway_Transit' }; async onTick() { - const shipments:Shipment[] = await this.shipmentModel.findBy({ finished: false }); - shipments.forEach(shipment => { - this.logisticsService.updateShipmentState(shipment); - }); + try { + const shipments:Shipment[] = await this.shipmentModel.findBy({ finished: false }); + shipments.forEach(shipment => { + this.logisticsService.updateShipmentState(shipment); + }); + } catch (error) { + this.logger.error(`更新运单状态失败 ${error.message}`); + } } onComplete(result: any) {