trendkit_core/error.rs
1//! Error type for trendkit-core.
2
3use thiserror::Error;
4
5/// Fallible result alias used throughout trendkit.
6pub type Result<T> = std::result::Result<T, TrendError>;
7
8/// Errors surfaced by trendkit-core.
9#[derive(Debug, Error)]
10pub enum TrendError {
11 /// A SQLite store operation failed.
12 #[error("database error: {0}")]
13 Db(#[from] rusqlite::Error),
14
15 /// An HTTP fetch failed.
16 #[error("fetch error: {0}")]
17 Fetch(#[from] fetch_kit::FetchError),
18
19 /// A filesystem operation failed.
20 #[error("io error: {0}")]
21 Io(#[from] std::io::Error),
22
23 /// A source stayed rate-limited after exhausting the retry budget.
24 #[error("rate limited after {attempts} attempts on {endpoint}")]
25 RateLimited {
26 /// The API endpoint that kept answering 403/429.
27 endpoint: String,
28 /// How many attempts were made.
29 attempts: u32,
30 },
31
32 /// Configuration could not be loaded or is contradictory.
33 #[error("config error: {0}")]
34 Config(String),
35
36 /// Anything that does not fit a typed variant yet.
37 #[error("{0}")]
38 Other(String),
39}