- Restructure from Modular MVC to Clean Architecture with 4 strict layers - Domain: entities (anime/komik/proxy), Repository traits, typed errors - Application: use case classes with proper error propagation - Infrastructure: repository impls, parsers, Redis cache, HTTP/scraping, browser - Presentation: Axum handlers, DTOs, AppState, router, AppError+IntoResponse - Migrate all parsers (otakudesu, alqanime, komik) to native infra implementations - Replace once_cell::sync::Lazy/OnceCell with std::sync::LazyLock/OnceLock - Remove 150+ old files in modules/ and shared/ directories - Remove once_cell from Cargo.toml dependencies - Fix test/debug binaries to use new import paths - Zero new clippy warnings Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
56 lines
1.4 KiB
Rust
56 lines
1.4 KiB
Rust
//! Domain-level error types.
|
|
//!
|
|
//! These are framework-agnostic errors that can be mapped to HTTP errors
|
|
//! at the presentation layer. Domain and application layers only use these.
|
|
|
|
use thiserror::Error;
|
|
|
|
/// Errors originating from repository operations (DB, HTTP, etc.)
|
|
#[derive(Error, Debug)]
|
|
pub enum RepositoryError {
|
|
#[error("Not found")]
|
|
NotFound,
|
|
#[error("Conflict: {0}")]
|
|
Conflict(String),
|
|
#[error("Database error: {0}")]
|
|
Database(String),
|
|
#[error("Network error: {0}")]
|
|
Network(String),
|
|
}
|
|
|
|
/// Errors originating from scraping/parsing operations
|
|
#[derive(Error, Debug)]
|
|
pub enum ScrapingError {
|
|
#[error("HTTP error: {0}")]
|
|
Http(String),
|
|
#[error("Parse error: {0}")]
|
|
Parse(String),
|
|
#[error("Empty response")]
|
|
EmptyResponse,
|
|
}
|
|
|
|
/// Generic domain error
|
|
#[derive(Error, Debug)]
|
|
pub enum DomainError {
|
|
#[error("Not found: {0}")]
|
|
NotFound(String),
|
|
#[error("Validation error: {0}")]
|
|
Validation(String),
|
|
#[error("Repository error: {0}")]
|
|
Repository(#[from] RepositoryError),
|
|
#[error("Scraping error: {0}")]
|
|
Scraping(#[from] ScrapingError),
|
|
}
|
|
|
|
impl From<String> for RepositoryError {
|
|
fn from(s: String) -> Self {
|
|
RepositoryError::Database(s)
|
|
}
|
|
}
|
|
|
|
impl From<&str> for RepositoryError {
|
|
fn from(s: &str) -> Self {
|
|
RepositoryError::Database(s.to_string())
|
|
}
|
|
}
|