feat(domain): add DomainError::UniqueViolation {field}

This commit is contained in:
2026-05-16 10:55:58 +02:00
parent 65ec64a4d9
commit ca35e8e774
2 changed files with 5 additions and 0 deletions

View File

@@ -27,6 +27,9 @@ impl IntoResponse for ApiError {
}
Self::Domain(DomainError::Forbidden) => (StatusCode::FORBIDDEN, "forbidden".into()),
Self::Domain(DomainError::Conflict(m)) => (StatusCode::CONFLICT, m),
Self::Domain(DomainError::UniqueViolation { field }) => {
(StatusCode::CONFLICT, format!("{field} already taken"))
}
Self::Domain(DomainError::InvalidInput(m)) => (StatusCode::UNPROCESSABLE_ENTITY, m),
Self::Domain(DomainError::ExternalService(_)) => {
(StatusCode::BAD_GATEWAY, "external service error".into())