Moved some errors around.

This commit is contained in:
2026-10-12 17:18:32 +02:00
parent a290610216
commit 05492123d7
5 changed files with 27 additions and 27 deletions
+1 -1
View File
@@ -95,7 +95,7 @@ async fn upsert_account_member(
let member = member.into_domain(member_id, account_id)?;
let user = repository::users::get_by_id(&pool, member.user_id)
.await?
.ok_or(AppError::UserIdNotFound)?;
.ok_or(AppError::UserNotFound)?;
let upserted = repository::account_members::upsert(&pool, user_id, member)
.await?
.ok_or(AppError::NotFound)?;
+12 -12
View File
@@ -25,29 +25,29 @@ impl IntoResponse for AppError {
impl ClientError for AppError {
fn client_response(&self) -> (StatusCode, Cow<'_, str>) {
match self {
Self::AccountNotFound => (
StatusCode::UNPROCESSABLE_ENTITY,
"Account cannot be found".into(),
),
Self::UserNotFound => (
StatusCode::UNPROCESSABLE_ENTITY,
"User cannot be found".into(),
),
Self::AccountIdAlreadyExists => {
(StatusCode::CONFLICT, "Account ID already exists".into())
}
Self::AccountIdNotFound => (
StatusCode::UNPROCESSABLE_ENTITY,
"Account ID cannot be found".into(),
),
Self::TransactionIdAlreadyExists => {
(StatusCode::CONFLICT, "Transaction ID already exists".into())
}
Self::AppIdAlreadyExists => (StatusCode::CONFLICT, "App ID already exists".into()),
Self::ScheduledTransactionIdAlreadyExists => (
StatusCode::CONFLICT,
"Scheduled transaction ID already exists".into(),
),
Self::AppIdAlreadyExists => (StatusCode::CONFLICT, "App ID already exists".into()),
Self::TransactionIdAlreadyExists => {
(StatusCode::CONFLICT, "Transaction ID already exists".into())
}
Self::LastAccountMemberRemoval => (
StatusCode::CONFLICT,
"Cannot remove the last member of an account".into(),
),
Self::UserIdNotFound => (
StatusCode::UNPROCESSABLE_ENTITY,
"User ID cannot be found".into(),
),
Self::InvalidClientCredentials => (
StatusCode::UNAUTHORIZED,
"Invalid client credentials".into(),
+1 -1
View File
@@ -94,7 +94,7 @@ async fn upsert_scheduled_transaction(
let transaction = transaction.into_domain(id)?;
let account = repository::accounts::get_by_id(&pool, user_id, transaction.account_id)
.await?
.ok_or(AppError::AccountIdNotFound)?;
.ok_or(AppError::AccountNotFound)?;
let upserted = repository::recurring_transactions::upsert(&pool, user_id, transaction)
.await?
.ok_or(AppError::ScheduledTransactionIdAlreadyExists)?;
+1 -1
View File
@@ -88,7 +88,7 @@ async fn upsert_transaction(
let transaction = transaction.into_domain(id)?;
let account = repository::accounts::get_by_id(&pool, user_id, transaction.account_id)
.await?
.ok_or(AppError::AccountIdNotFound)?;
.ok_or(AppError::AccountNotFound)?;
let upserted = repository::transactions::upsert(&pool, user_id, transaction)
.await?
.ok_or(AppError::TransactionIdAlreadyExists)?;