Files
movies-diary/crates/domain/src/errors.rs
Gabriel Kaszewski 4067dedb28 refactor: add DomainError::Forbidden + centralize error-to-HTTP mapping
Ownership checks (delete_review, confirm/dismiss watch events) now
return Forbidden instead of Unauthorized. Presentation layer maps
DomainError→StatusCode via domain_error_response helper, replacing
verbose per-handler match arms.
2026-06-02 21:00:22 +02:00

23 lines
517 B
Rust

use thiserror::Error;
#[derive(Error, Debug)]
pub enum DomainError {
#[error("Rating must be between 0 and {max}, but received {given}")]
InvalidRating { max: u8, given: u8 },
#[error("Entity not found: {0}")]
NotFound(String),
#[error("Business rule violation: {0}")]
ValidationError(String),
#[error("Infrastructure failure: {0}")]
InfrastructureError(String),
#[error("Unauthorized: {0}")]
Unauthorized(String),
#[error("Forbidden: {0}")]
Forbidden(String),
}