refactor: replace IntoServiceError trait with direct ServiceError conversions
This commit is contained in:
@@ -7,7 +7,7 @@ use sea_orm::{
|
||||
IntoActiveModel, QueryFilter,
|
||||
};
|
||||
|
||||
use crate::errors::service_error::{IntoServiceError, ServiceError};
|
||||
use crate::errors::service_error::ServiceError;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
pub trait SettingsStore: Send + Sync {
|
||||
@@ -37,11 +37,11 @@ impl SettingsStore for SettingsService {
|
||||
.await;
|
||||
|
||||
match setting {
|
||||
Err(err) => Err(err.into_service_error()),
|
||||
Ok(None) => Err(
|
||||
DbErr::RecordNotFound(format!("Setting with key '{}' not found", key))
|
||||
.into_service_error(),
|
||||
),
|
||||
Err(err) => Err(ServiceError::from(err)),
|
||||
Ok(None) => Err(ServiceError::from(DbErr::RecordNotFound(format!(
|
||||
"Setting with key '{}' not found",
|
||||
key
|
||||
)))),
|
||||
Ok(Some(record)) => Ok(record.value),
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,7 @@ impl SettingsStore for SettingsService {
|
||||
new_record
|
||||
.insert(&*self.connection)
|
||||
.await
|
||||
.map_err(|err| err.into_service_error())
|
||||
.map_err(ServiceError::from)
|
||||
};
|
||||
|
||||
match existing {
|
||||
@@ -71,7 +71,7 @@ impl SettingsStore for SettingsService {
|
||||
handle_not_found(key.to_string(), value).await?;
|
||||
}
|
||||
_ => {
|
||||
return Err(Box::new(err));
|
||||
return Err(ServiceError::from(err));
|
||||
}
|
||||
},
|
||||
Ok(None) => {
|
||||
@@ -83,7 +83,7 @@ impl SettingsStore for SettingsService {
|
||||
.into_active_model()
|
||||
.update(&*self.connection)
|
||||
.await
|
||||
.map_err(|err| err.into_service_error())?;
|
||||
.map_err(ServiceError::from)?;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user