Added user apps and token resources.
This commit is contained in:
@@ -16,6 +16,9 @@ pub enum AppError {
|
||||
#[error("not found")]
|
||||
NotFound,
|
||||
|
||||
#[error("unauthorized")]
|
||||
Unauthorized,
|
||||
|
||||
#[error("domain error")]
|
||||
Domain(#[from] DomainError),
|
||||
|
||||
@@ -35,6 +38,9 @@ impl IntoResponse for AppError {
|
||||
Self::NotFound => {
|
||||
return error_response(StatusCode::NOT_FOUND, "Not found");
|
||||
}
|
||||
Self::Unauthorized => {
|
||||
return error_response(StatusCode::UNAUTHORIZED, "Unauthorized");
|
||||
}
|
||||
Self::Domain(error) => {
|
||||
return error_response(StatusCode::UNPROCESSABLE_ENTITY, error.to_string());
|
||||
}
|
||||
@@ -44,6 +50,20 @@ impl IntoResponse for AppError {
|
||||
Self::Repository(RepositoryError::Decode(error)) => {
|
||||
tracing::error!(%error, "invalid stored data");
|
||||
}
|
||||
Self::Repository(RepositoryError::ReferenceViolation {
|
||||
relation: ReferenceRelation::User,
|
||||
kind: ReferenceViolationKind::Missing,
|
||||
..
|
||||
}) => {
|
||||
return error_response(StatusCode::NOT_FOUND, "User cannot be found");
|
||||
}
|
||||
Self::Repository(RepositoryError::ReferenceViolation {
|
||||
relation: ReferenceRelation::UserApp,
|
||||
kind: ReferenceViolationKind::Missing,
|
||||
..
|
||||
}) => {
|
||||
return error_response(StatusCode::NOT_FOUND, "User app cannot be found");
|
||||
}
|
||||
Self::Repository(RepositoryError::ReferenceViolation {
|
||||
relation: ReferenceRelation::Account,
|
||||
kind: ReferenceViolationKind::Missing,
|
||||
|
||||
Reference in New Issue
Block a user