Added source and destination accounts.
This commit is contained in:
@@ -2,3 +2,23 @@ pub mod accounts;
|
||||
pub mod dtos;
|
||||
pub mod recurring_transactions;
|
||||
pub mod transactions;
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum DatabaseError {
|
||||
#[error("Foreign key violation")]
|
||||
ForeignKeyViolation,
|
||||
|
||||
#[error("Internal error: {0}")]
|
||||
Internal(#[source] sqlx::Error),
|
||||
}
|
||||
|
||||
impl From<sqlx::Error> for DatabaseError {
|
||||
fn from(err: sqlx::Error) -> Self {
|
||||
match err {
|
||||
sqlx::Error::Database(db_err) if db_err.code().as_deref() == Some("23503") => {
|
||||
DatabaseError::ForeignKeyViolation
|
||||
}
|
||||
_ => DatabaseError::Internal(err),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user