use serde::{Deserialize, Serialize};
use thiserror::Error;
#[derive(Error, Debug, Serialize, Deserialize)]
pub enum CoreError {
#[error("Video processing error: {0}")]
VideoProcessingError(String),
#[error("AI commentary generation error: {0}")]
CommentaryError(String),
#[error("Storage error: {0}")]
StorageError(#[from] crate::storage::StorageError),
#[error("Configuration error: {0}")]
ConfigError(#[from] crate::config::ConfigError),
#[error("Invalid input: {0}")]
InvalidInput(String),
#[error("Unauthorized access")]
Unauthorized,
#[error("Forbidden access")]
Forbidden,
#[error("Resource not found: {0}")]
NotFound(String),
#[error("Internal server error: {0}")]
InternalError(String),
#[error("Network error: {0}")]
NetworkError(String),
#[error("Timeout error")]
Timeout,
#[error("Serialization error: {0}")]
SerializationError(String),
#[error("Deserialization error: {0}")]
DeserializationError(String),
#[error("IO error: {0}")]
IoError(String),
#[error("JSON serialization error: {0}")]
JsonError(String),
}
pub type Result<T> = std::result::Result<T, CoreError>;
impl CoreError {
pub fn video_processing_error(msg: &str) -> Self {
CoreError::VideoProcessingError(msg.to_string())
}
pub fn commentary_error(msg: &str) -> Self {
CoreError::CommentaryError(msg.to_string())
}
pub fn invalid_input(msg: &str) -> Self {
CoreError::InvalidInput(msg.to_string())
}
pub fn not_found(resource: &str) -> Self {
CoreError::NotFound(resource.to_string())
}
pub fn internal_error(msg: &str) -> Self {
CoreError::InternalError(msg.to_string())
}
pub fn network_error(msg: &str) -> Self {
CoreError::NetworkError(msg.to_string())
}
pub fn serialization_error(msg: &str) -> Self {
CoreError::SerializationError(msg.to_string())
}
pub fn deserialization_error(msg: &str) -> Self {
CoreError::DeserializationError(msg.to_string())
}
pub fn io_error(msg: &str) -> Self {
CoreError::IoError(msg.to_string())
}
pub fn json_error(msg: &str) -> Self {
CoreError::JsonError(msg.to_string())
}
}