pub mod classifier;
pub mod config;
pub mod fetcher;
pub mod parser;
pub mod repository;
pub mod scheduler;
pub mod service;
pub mod types;

use thiserror::Error;

pub use service::NewsService;
pub use types::{
    NewsArticle, NewsSourceConfig, QueryNewsFeedRequest, QueryNewsFeedResponse,
    RefreshNewsFeedRequest, RefreshNewsFeedResult, SaveNewsFeedConfigRequest,
    UpdateNewsArticleStateRequest,
};

#[derive(Debug, Error)]
pub enum NewsError {
    #[error("news configuration error: {0}")]
    Config(String),
    #[error("news I/O failed: {0}")]
    Io(#[from] std::io::Error),
    #[error("news HTTP request failed: {0}")]
    Http(#[from] reqwest::Error),
    #[error("news database failed: {0}")]
    Db(#[from] rusqlite::Error),
    #[error("news JSON failed: {0}")]
    Json(#[from] serde_json::Error),
    #[error("news task join failed: {0}")]
    Join(String),
    #[error("news parse failed: {0}")]
    Parse(String),
    #[error("unknown news article: {0}")]
    ArticleNotFound(String),
}

pub type Result<T> = std::result::Result<T, NewsError>;
