feat: Replace RedisOperation with DatabaseError in rating_plans_repo error mapping

- Replace RedisOperation error variant with DatabaseError in new/get/list_map/add/remove methods
- Update 5 map_err calls to use DatabaseError for SQLx operation failures
This commit is contained in:
nutcas3
2026-04-25 03:03:27 +03:00
parent 69a84d85e6
commit 7e47f09e54
@@ -49,7 +49,7 @@ impl RatingPlansRepo {
)
.execute(&pool)
.await
.map_err(|e| crate::errors::ChargingError::RedisOperation(e.to_string()))?;
.map_err(|e| crate::errors::ChargingError::DatabaseError(e.to_string()))?;
Ok(Self { pool })
}
@@ -112,7 +112,7 @@ impl RatingPlansRepo {
.bind(plan_id)
.fetch_optional(&self.pool)
.await
.map_err(|e| crate::errors::ChargingError::RedisOperation(e.to_string()))?;
.map_err(|e| crate::errors::ChargingError::DatabaseError(e.to_string()))?;
Ok(row.map(row_to_plan))
}
@@ -129,7 +129,7 @@ impl RatingPlansRepo {
)
.fetch_all(&self.pool)
.await
.map_err(|e| crate::errors::ChargingError::RedisOperation(e.to_string()))?;
.map_err(|e| crate::errors::ChargingError::DatabaseError(e.to_string()))?;
let mut out = HashMap::with_capacity(rows.len());
for row in rows {
@@ -192,7 +192,7 @@ impl RatingPlansRepo {
.bind(plan.sms_limit as i64)
.execute(&self.pool)
.await
.map_err(|e| crate::errors::ChargingError::RedisOperation(e.to_string()))?;
.map_err(|e| crate::errors::ChargingError::DatabaseError(e.to_string()))?;
Ok(())
}
@@ -204,7 +204,7 @@ impl RatingPlansRepo {
.bind(plan_id)
.execute(&self.pool)
.await
.map_err(|e| crate::errors::ChargingError::RedisOperation(e.to_string()))?;
.map_err(|e| crate::errors::ChargingError::DatabaseError(e.to_string()))?;
Ok(result.rows_affected() > 0)
}
}