From 0517ddd02ee49a27b7c7d6f97b080764937743ed Mon Sep 17 00:00:00 2001 From: Rogier Reerink Date: Fri, 9 Oct 2026 12:24:02 +0200 Subject: [PATCH] Trace all app errors. --- server/src/error.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/server/src/error.rs b/server/src/error.rs index 228545f..086eac7 100644 --- a/server/src/error.rs +++ b/server/src/error.rs @@ -33,15 +33,19 @@ impl IntoResponse for AppError { fn into_response(self) -> Response { match self { Self::BadRequest(error) => { + tracing::debug!(%error, "bad request"); return error_response(StatusCode::BAD_REQUEST, error); } Self::NotFound => { + tracing::debug!("not found"); return error_response(StatusCode::NOT_FOUND, "Not found"); } Self::Unauthorized => { + tracing::debug!("unauthorized"); return error_response(StatusCode::UNAUTHORIZED, "Unauthorized"); } Self::Domain(error) => { + tracing::debug!(%error, "domain error"); return error_response(StatusCode::UNPROCESSABLE_ENTITY, error.to_string()); } Self::Repository(RepositoryError::Database(error)) => { @@ -59,11 +63,13 @@ impl IntoResponse for AppError { Self::Repository(RepositoryError::NotFound { relation: ReferenceRelation::User, }) => { + tracing::debug!("user not found"); return error_response(StatusCode::NOT_FOUND, "User cannot be found"); } Self::Repository(RepositoryError::NotFound { relation: ReferenceRelation::UserApp, }) => { + tracing::debug!("user app not found"); return error_response(StatusCode::NOT_FOUND, "User app cannot be found"); } Self::Repository(RepositoryError::OwnershipConflict { relation }) => { @@ -77,6 +83,7 @@ impl IntoResponse for AppError { kind: ReferenceViolationKind::Missing, .. }) => { + tracing::debug!("user not found (reference violation)"); return error_response(StatusCode::NOT_FOUND, "User cannot be found"); } Self::Repository(RepositoryError::ReferenceViolation { @@ -84,6 +91,7 @@ impl IntoResponse for AppError { kind: ReferenceViolationKind::Missing, .. }) => { + tracing::debug!("user app not found (reference violation)"); return error_response(StatusCode::NOT_FOUND, "User app cannot be found"); } Self::Repository(RepositoryError::ReferenceViolation { @@ -91,6 +99,7 @@ impl IntoResponse for AppError { kind: ReferenceViolationKind::Missing, .. }) => { + tracing::debug!("account not found (reference violation)"); return error_response(StatusCode::UNPROCESSABLE_ENTITY, "Account cannot be found"); } Self::Repository(RepositoryError::ReferenceViolation { @@ -98,6 +107,9 @@ impl IntoResponse for AppError { kind: ReferenceViolationKind::StillReferenced, .. }) => { + tracing::debug!( + "still referenced by one or more transactions (reference violation)" + ); return error_response( StatusCode::CONFLICT, "Still referenced by one or more transactions", @@ -108,6 +120,9 @@ impl IntoResponse for AppError { kind: ReferenceViolationKind::StillReferenced, .. }) => { + tracing::debug!( + "still referenced by one or more recurring transactions (reference violation)" + ); return error_response( StatusCode::CONFLICT, "Still referenced by one or more recurring transactions", @@ -121,6 +136,7 @@ impl IntoResponse for AppError { tracing::error!(%relation, %kind, error = ?source, "unhandled reference violation"); } Self::Repository(RepositoryError::QueryConversion(error)) => { + tracing::debug!(%error, "query conversion error"); return error_response(StatusCode::BAD_REQUEST, error.to_string()); } Self::Internal => {