These errors have become app level errors.
This commit is contained in:
+7
-24
@@ -13,6 +13,9 @@ pub enum AppError {
|
||||
#[error("bad request")]
|
||||
BadRequest(String),
|
||||
|
||||
#[error("conflict")]
|
||||
Conflict(String),
|
||||
|
||||
#[error("not found")]
|
||||
NotFound,
|
||||
|
||||
@@ -36,6 +39,10 @@ impl IntoResponse for AppError {
|
||||
tracing::debug!(%error, "bad request");
|
||||
return error_response(StatusCode::BAD_REQUEST, error);
|
||||
}
|
||||
Self::Conflict(error) => {
|
||||
tracing::warn!(%error, "conflict");
|
||||
return error_response(StatusCode::CONFLICT, error);
|
||||
}
|
||||
Self::NotFound => {
|
||||
tracing::debug!("not found");
|
||||
return error_response(StatusCode::NOT_FOUND, "Not found");
|
||||
@@ -54,30 +61,6 @@ impl IntoResponse for AppError {
|
||||
Self::Repository(RepositoryError::Decode(error)) => {
|
||||
tracing::error!(%error, "invalid stored data");
|
||||
}
|
||||
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::NotFound { relation }) => {
|
||||
tracing::error!(%relation, "unhandled not found");
|
||||
}
|
||||
Self::Repository(RepositoryError::OwnershipConflict {
|
||||
relation: ReferenceRelation::UserApp,
|
||||
}) => {
|
||||
tracing::warn!("user app ownership conflict");
|
||||
return error_response(StatusCode::CONFLICT, "User app ID is already in use");
|
||||
}
|
||||
Self::Repository(RepositoryError::OwnershipConflict { relation }) => {
|
||||
tracing::error!(%relation, "unhandled ownership conflict");
|
||||
}
|
||||
Self::Repository(RepositoryError::ReferenceViolation {
|
||||
relation: ReferenceRelation::User,
|
||||
kind: ReferenceViolationKind::Missing,
|
||||
|
||||
Reference in New Issue
Block a user