Add Forbidden error variant

This commit is contained in:
2026-04-15 21:14:01 +02:00
parent 1486c4db9e
commit 1fa737a2e6
+4
View File
@@ -6,6 +6,9 @@ pub enum AppError {
Unauthorized, Unauthorized,
BadRequest(String), BadRequest(String),
NotFound(String), NotFound(String),
/// 403 — authenticated but lacks permission (e.g. non-admin calling an
/// admin-only endpoint).
Forbidden(String),
/// 409 — request is valid but conflicts with current state (e.g. an /// 409 — request is valid but conflicts with current state (e.g. an
/// analysis is already running for this case). /// analysis is already running for this case).
Conflict(String), Conflict(String),
@@ -30,6 +33,7 @@ impl IntoResponse for AppError {
Self::Unauthorized => (StatusCode::UNAUTHORIZED, "Unauthorized".to_owned()), Self::Unauthorized => (StatusCode::UNAUTHORIZED, "Unauthorized".to_owned()),
Self::BadRequest(msg) => (StatusCode::BAD_REQUEST, msg.clone()), Self::BadRequest(msg) => (StatusCode::BAD_REQUEST, msg.clone()),
Self::NotFound(msg) => (StatusCode::NOT_FOUND, msg.clone()), Self::NotFound(msg) => (StatusCode::NOT_FOUND, msg.clone()),
Self::Forbidden(msg) => (StatusCode::FORBIDDEN, msg.clone()),
Self::Conflict(msg) => (StatusCode::CONFLICT, msg.clone()), Self::Conflict(msg) => (StatusCode::CONFLICT, msg.clone()),
Self::ServiceUnavailable(msg) => (StatusCode::SERVICE_UNAVAILABLE, msg.clone()), Self::ServiceUnavailable(msg) => (StatusCode::SERVICE_UNAVAILABLE, msg.clone()),
Self::Internal(msg) => (StatusCode::INTERNAL_SERVER_ERROR, msg.clone()), Self::Internal(msg) => (StatusCode::INTERNAL_SERVER_ERROR, msg.clone()),