Trace all app errors.

This commit is contained in:
2026-10-09 12:24:02 +02:00
parent e68f103c29
commit 0517ddd02e
+16
View File
@@ -33,15 +33,19 @@ impl IntoResponse for AppError {
fn into_response(self) -> Response { fn into_response(self) -> Response {
match self { match self {
Self::BadRequest(error) => { Self::BadRequest(error) => {
tracing::debug!(%error, "bad request");
return error_response(StatusCode::BAD_REQUEST, error); return error_response(StatusCode::BAD_REQUEST, error);
} }
Self::NotFound => { Self::NotFound => {
tracing::debug!("not found");
return error_response(StatusCode::NOT_FOUND, "Not found"); return error_response(StatusCode::NOT_FOUND, "Not found");
} }
Self::Unauthorized => { Self::Unauthorized => {
tracing::debug!("unauthorized");
return error_response(StatusCode::UNAUTHORIZED, "Unauthorized"); return error_response(StatusCode::UNAUTHORIZED, "Unauthorized");
} }
Self::Domain(error) => { Self::Domain(error) => {
tracing::debug!(%error, "domain error");
return error_response(StatusCode::UNPROCESSABLE_ENTITY, error.to_string()); return error_response(StatusCode::UNPROCESSABLE_ENTITY, error.to_string());
} }
Self::Repository(RepositoryError::Database(error)) => { Self::Repository(RepositoryError::Database(error)) => {
@@ -59,11 +63,13 @@ impl IntoResponse for AppError {
Self::Repository(RepositoryError::NotFound { Self::Repository(RepositoryError::NotFound {
relation: ReferenceRelation::User, relation: ReferenceRelation::User,
}) => { }) => {
tracing::debug!("user not found");
return error_response(StatusCode::NOT_FOUND, "User cannot be found"); return error_response(StatusCode::NOT_FOUND, "User cannot be found");
} }
Self::Repository(RepositoryError::NotFound { Self::Repository(RepositoryError::NotFound {
relation: ReferenceRelation::UserApp, relation: ReferenceRelation::UserApp,
}) => { }) => {
tracing::debug!("user app not found");
return error_response(StatusCode::NOT_FOUND, "User app cannot be found"); return error_response(StatusCode::NOT_FOUND, "User app cannot be found");
} }
Self::Repository(RepositoryError::OwnershipConflict { relation }) => { Self::Repository(RepositoryError::OwnershipConflict { relation }) => {
@@ -77,6 +83,7 @@ impl IntoResponse for AppError {
kind: ReferenceViolationKind::Missing, kind: ReferenceViolationKind::Missing,
.. ..
}) => { }) => {
tracing::debug!("user not found (reference violation)");
return error_response(StatusCode::NOT_FOUND, "User cannot be found"); return error_response(StatusCode::NOT_FOUND, "User cannot be found");
} }
Self::Repository(RepositoryError::ReferenceViolation { Self::Repository(RepositoryError::ReferenceViolation {
@@ -84,6 +91,7 @@ impl IntoResponse for AppError {
kind: ReferenceViolationKind::Missing, kind: ReferenceViolationKind::Missing,
.. ..
}) => { }) => {
tracing::debug!("user app not found (reference violation)");
return error_response(StatusCode::NOT_FOUND, "User app cannot be found"); return error_response(StatusCode::NOT_FOUND, "User app cannot be found");
} }
Self::Repository(RepositoryError::ReferenceViolation { Self::Repository(RepositoryError::ReferenceViolation {
@@ -91,6 +99,7 @@ impl IntoResponse for AppError {
kind: ReferenceViolationKind::Missing, kind: ReferenceViolationKind::Missing,
.. ..
}) => { }) => {
tracing::debug!("account not found (reference violation)");
return error_response(StatusCode::UNPROCESSABLE_ENTITY, "Account cannot be found"); return error_response(StatusCode::UNPROCESSABLE_ENTITY, "Account cannot be found");
} }
Self::Repository(RepositoryError::ReferenceViolation { Self::Repository(RepositoryError::ReferenceViolation {
@@ -98,6 +107,9 @@ impl IntoResponse for AppError {
kind: ReferenceViolationKind::StillReferenced, kind: ReferenceViolationKind::StillReferenced,
.. ..
}) => { }) => {
tracing::debug!(
"still referenced by one or more transactions (reference violation)"
);
return error_response( return error_response(
StatusCode::CONFLICT, StatusCode::CONFLICT,
"Still referenced by one or more transactions", "Still referenced by one or more transactions",
@@ -108,6 +120,9 @@ impl IntoResponse for AppError {
kind: ReferenceViolationKind::StillReferenced, kind: ReferenceViolationKind::StillReferenced,
.. ..
}) => { }) => {
tracing::debug!(
"still referenced by one or more recurring transactions (reference violation)"
);
return error_response( return error_response(
StatusCode::CONFLICT, StatusCode::CONFLICT,
"Still referenced by one or more recurring transactions", "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"); tracing::error!(%relation, %kind, error = ?source, "unhandled reference violation");
} }
Self::Repository(RepositoryError::QueryConversion(error)) => { Self::Repository(RepositoryError::QueryConversion(error)) => {
tracing::debug!(%error, "query conversion error");
return error_response(StatusCode::BAD_REQUEST, error.to_string()); return error_response(StatusCode::BAD_REQUEST, error.to_string());
} }
Self::Internal => { Self::Internal => {