2026-04-07 02:50:19 +08:00
|
|
|
pub use aether_data_contracts::DataLayerError;
|
2026-03-24 15:12:56 +08:00
|
|
|
|
2026-07-15 23:47:19 +08:00
|
|
|
#[cfg(feature = "postgres")]
|
2026-04-07 02:50:19 +08:00
|
|
|
pub(crate) fn postgres_error(error: impl std::fmt::Display) -> DataLayerError {
|
|
|
|
|
DataLayerError::postgres(error)
|
|
|
|
|
}
|
2026-03-24 15:12:56 +08:00
|
|
|
|
2026-05-05 18:27:36 +08:00
|
|
|
pub(crate) fn sql_error(error: impl std::fmt::Display) -> DataLayerError {
|
|
|
|
|
DataLayerError::sql(error)
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-15 23:47:19 +08:00
|
|
|
#[cfg(feature = "postgres")]
|
2026-04-07 02:50:19 +08:00
|
|
|
pub(crate) trait SqlxResultExt<T> {
|
|
|
|
|
fn map_postgres_err(self) -> Result<T, DataLayerError>;
|
|
|
|
|
}
|
2026-03-24 15:12:56 +08:00
|
|
|
|
2026-07-15 23:47:19 +08:00
|
|
|
#[cfg(feature = "postgres")]
|
2026-04-07 02:50:19 +08:00
|
|
|
impl<T> SqlxResultExt<T> for Result<T, sqlx::Error> {
|
|
|
|
|
fn map_postgres_err(self) -> Result<T, DataLayerError> {
|
|
|
|
|
self.map_err(postgres_error)
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-03-24 15:12:56 +08:00
|
|
|
|
2026-05-05 18:27:36 +08:00
|
|
|
pub(crate) trait SqlResultExt<T> {
|
|
|
|
|
fn map_sql_err(self) -> Result<T, DataLayerError>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<T> SqlResultExt<T> for Result<T, sqlx::Error> {
|
|
|
|
|
fn map_sql_err(self) -> Result<T, DataLayerError> {
|
|
|
|
|
self.map_err(sql_error)
|
|
|
|
|
}
|
|
|
|
|
}
|