mirror of
https://github.com/andwati/telecom-platform.git
synced 2026-11-17 09:25:11 +00:00
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:
@@ -49,7 +49,7 @@ impl RatingPlansRepo {
|
|||||||
)
|
)
|
||||||
.execute(&pool)
|
.execute(&pool)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| crate::errors::ChargingError::RedisOperation(e.to_string()))?;
|
.map_err(|e| crate::errors::ChargingError::DatabaseError(e.to_string()))?;
|
||||||
|
|
||||||
Ok(Self { pool })
|
Ok(Self { pool })
|
||||||
}
|
}
|
||||||
@@ -112,7 +112,7 @@ impl RatingPlansRepo {
|
|||||||
.bind(plan_id)
|
.bind(plan_id)
|
||||||
.fetch_optional(&self.pool)
|
.fetch_optional(&self.pool)
|
||||||
.await
|
.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))
|
Ok(row.map(row_to_plan))
|
||||||
}
|
}
|
||||||
@@ -129,7 +129,7 @@ impl RatingPlansRepo {
|
|||||||
)
|
)
|
||||||
.fetch_all(&self.pool)
|
.fetch_all(&self.pool)
|
||||||
.await
|
.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());
|
let mut out = HashMap::with_capacity(rows.len());
|
||||||
for row in rows {
|
for row in rows {
|
||||||
@@ -192,7 +192,7 @@ impl RatingPlansRepo {
|
|||||||
.bind(plan.sms_limit as i64)
|
.bind(plan.sms_limit as i64)
|
||||||
.execute(&self.pool)
|
.execute(&self.pool)
|
||||||
.await
|
.await
|
||||||
.map_err(|e| crate::errors::ChargingError::RedisOperation(e.to_string()))?;
|
.map_err(|e| crate::errors::ChargingError::DatabaseError(e.to_string()))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,7 +204,7 @@ impl RatingPlansRepo {
|
|||||||
.bind(plan_id)
|
.bind(plan_id)
|
||||||
.execute(&self.pool)
|
.execute(&self.pool)
|
||||||
.await
|
.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)
|
Ok(result.rows_affected() > 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user