Implemented a domain layer, because the API DTO's where getting bloated.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
mod encoding;
|
||||
pub mod recurring_transactions;
|
||||
pub mod transactions;
|
||||
|
||||
pub use crate::database::common::{Delete, Upsert};
|
||||
use crate::domain::{CentsConversionError, RecurrenceIntervalError, ValidationError};
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum RepositoryError {
|
||||
#[error(transparent)]
|
||||
Database(#[from] sqlx::Error),
|
||||
|
||||
#[error(transparent)]
|
||||
Decode(#[from] DecodeError),
|
||||
}
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum DecodeError {
|
||||
#[error(transparent)]
|
||||
Amount(#[from] CentsConversionError),
|
||||
|
||||
#[error(transparent)]
|
||||
RecurrenceInterval(#[from] RecurrenceIntervalError),
|
||||
|
||||
#[error(transparent)]
|
||||
Invalid(#[from] ValidationError),
|
||||
|
||||
#[error("invalid direction value: {0}")]
|
||||
Direction(String),
|
||||
|
||||
#[error("invalid recurrence_unit value: {0}")]
|
||||
RecurrenceUnit(String),
|
||||
|
||||
#[error("invalid weekend_adjustment value: {0}")]
|
||||
WeekendAdjustment(String),
|
||||
}
|
||||
Reference in New Issue
Block a user