Trace all app errors.
This commit is contained in:
@@ -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 => {
|
||||
|
||||
Reference in New Issue
Block a user