diff --git a/crates/erp-health/src/service/critical_alert_service.rs b/crates/erp-health/src/service/critical_alert_service.rs index dd85abe..3f5718e 100644 --- a/crates/erp-health/src/service/critical_alert_service.rs +++ b/crates/erp-health/src/service/critical_alert_service.rs @@ -191,14 +191,22 @@ pub async fn list_pending_alerts( let total = query .clone() .count(&state.db) - .await?; + .await + .map_err(|e| { + tracing::error!(error = %e, %tenant_id, "查询危急值告警总数失败"); + e + })?; let items = query .order_by(critical_alert::Column::CreatedAt, sea_orm::Order::Desc) .offset(offset) .limit(limit) .all(&state.db) - .await?; + .await + .map_err(|e| { + tracing::error!(error = %e, %tenant_id, "查询危急值告警列表失败"); + e + })?; Ok((items, total)) } @@ -211,7 +219,11 @@ pub async fn get_alert( ) -> HealthResult { let alert = critical_alert::Entity::find_by_id(alert_id) .one(&state.db) - .await? + .await + .map_err(|e| { + tracing::error!(error = %e, %alert_id, %tenant_id, "查询危急值告警详情失败"); + e + })? .ok_or(HealthError::CriticalAlertNotFound)?; if alert.tenant_id != tenant_id {