mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-28 04:04:55 +08:00
chore: address Rust 1.78 clippy lints (#4545)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -8,7 +8,7 @@ use hyperswitch_domain_models::errors::StorageError as DataStorageError;
|
||||
pub use redis_interface::errors::RedisError;
|
||||
use router_env::opentelemetry::metrics::MetricsError;
|
||||
|
||||
use crate::{errors as storage_errors, store::errors::DatabaseError};
|
||||
use crate::store::errors::DatabaseError;
|
||||
|
||||
pub type ApplicationResult<T> = Result<T, ApplicationError>;
|
||||
|
||||
@ -56,20 +56,16 @@ impl Into<DataStorageError> for &StorageError {
|
||||
fn into(self) -> DataStorageError {
|
||||
match self {
|
||||
StorageError::DatabaseError(i) => match i.current_context() {
|
||||
storage_errors::DatabaseError::DatabaseConnectionError => {
|
||||
DataStorageError::DatabaseConnectionError
|
||||
}
|
||||
DatabaseError::DatabaseConnectionError => DataStorageError::DatabaseConnectionError,
|
||||
// TODO: Update this error type to encompass & propagate the missing type (instead of generic `db value not found`)
|
||||
storage_errors::DatabaseError::NotFound => {
|
||||
DatabaseError::NotFound => {
|
||||
DataStorageError::ValueNotFound(String::from("db value not found"))
|
||||
}
|
||||
// TODO: Update this error type to encompass & propagate the duplicate type (instead of generic `db value not found`)
|
||||
storage_errors::DatabaseError::UniqueViolation => {
|
||||
DataStorageError::DuplicateValue {
|
||||
entity: "db entity",
|
||||
key: None,
|
||||
}
|
||||
}
|
||||
DatabaseError::UniqueViolation => DataStorageError::DuplicateValue {
|
||||
entity: "db entity",
|
||||
key: None,
|
||||
},
|
||||
err => DataStorageError::DatabaseError(error_stack::report!(*err)),
|
||||
},
|
||||
StorageError::ValueNotFound(i) => DataStorageError::ValueNotFound(i.clone()),
|
||||
|
||||
@ -217,7 +217,7 @@ impl<T: DatabaseStore> KVRouterStore<T> {
|
||||
partition_key: redis::kv_store::PartitionKey<'_>,
|
||||
) -> error_stack::Result<(), RedisError>
|
||||
where
|
||||
R: crate::redis::kv_store::KvStorePartition,
|
||||
R: redis::kv_store::KvStorePartition,
|
||||
{
|
||||
let global_id = format!("{}", partition_key);
|
||||
let request_id = self.request_id.clone().unwrap_or_default();
|
||||
|
||||
@ -41,9 +41,9 @@ pub struct MockDb {
|
||||
pub disputes: Arc<Mutex<Vec<store::Dispute>>>,
|
||||
pub lockers: Arc<Mutex<Vec<store::LockerMockUp>>>,
|
||||
pub mandates: Arc<Mutex<Vec<store::Mandate>>>,
|
||||
pub captures: Arc<Mutex<Vec<crate::store::capture::Capture>>>,
|
||||
pub merchant_key_store: Arc<Mutex<Vec<crate::store::merchant_key_store::MerchantKeyStore>>>,
|
||||
pub business_profiles: Arc<Mutex<Vec<crate::store::business_profile::BusinessProfile>>>,
|
||||
pub captures: Arc<Mutex<Vec<store::capture::Capture>>>,
|
||||
pub merchant_key_store: Arc<Mutex<Vec<store::merchant_key_store::MerchantKeyStore>>>,
|
||||
pub business_profiles: Arc<Mutex<Vec<store::business_profile::BusinessProfile>>>,
|
||||
pub reverse_lookups: Arc<Mutex<Vec<store::ReverseLookup>>>,
|
||||
pub payment_link: Arc<Mutex<Vec<store::payment_link::PaymentLink>>>,
|
||||
pub organizations: Arc<Mutex<Vec<store::organization::Organization>>>,
|
||||
|
||||
@ -257,7 +257,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
|
||||
_storage_scheme: MerchantStorageScheme,
|
||||
) -> error_stack::Result<PaymentAttempt, StorageError> {
|
||||
match payment.active_attempt.clone() {
|
||||
hyperswitch_domain_models::RemoteStorageObject::ForeignID(attempt_id) => {
|
||||
RemoteStorageObject::ForeignID(attempt_id) => {
|
||||
let conn = pg_connection_read(self).await?;
|
||||
|
||||
let pa = DieselPaymentAttempt::find_by_merchant_id_attempt_id(
|
||||
@ -271,11 +271,10 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
|
||||
er.change_context(new_err)
|
||||
})
|
||||
.map(PaymentAttempt::from_storage_model)?;
|
||||
payment.active_attempt =
|
||||
hyperswitch_domain_models::RemoteStorageObject::Object(pa.clone());
|
||||
payment.active_attempt = RemoteStorageObject::Object(pa.clone());
|
||||
Ok(pa)
|
||||
}
|
||||
hyperswitch_domain_models::RemoteStorageObject::Object(pa) => Ok(pa.clone()),
|
||||
RemoteStorageObject::Object(pa) => Ok(pa.clone()),
|
||||
}
|
||||
}
|
||||
|
||||
@ -397,7 +396,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
|
||||
_storage_scheme: MerchantStorageScheme,
|
||||
) -> error_stack::Result<PaymentAttempt, StorageError> {
|
||||
match &payment.active_attempt {
|
||||
hyperswitch_domain_models::RemoteStorageObject::ForeignID(attempt_id) => {
|
||||
RemoteStorageObject::ForeignID(attempt_id) => {
|
||||
let conn = pg_connection_read(self).await?;
|
||||
|
||||
let pa = DieselPaymentAttempt::find_by_merchant_id_attempt_id(
|
||||
@ -411,11 +410,10 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
|
||||
er.change_context(new_err)
|
||||
})
|
||||
.map(PaymentAttempt::from_storage_model)?;
|
||||
payment.active_attempt =
|
||||
hyperswitch_domain_models::RemoteStorageObject::Object(pa.clone());
|
||||
payment.active_attempt = RemoteStorageObject::Object(pa.clone());
|
||||
Ok(pa)
|
||||
}
|
||||
hyperswitch_domain_models::RemoteStorageObject::Object(pa) => Ok(pa.clone()),
|
||||
RemoteStorageObject::Object(pa) => Ok(pa.clone()),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user