stargazer/tier1/
error.rs

1//! Fetch error types for Tier 1 data source fetchers.
2//!
3//! Each fetcher converts its domain-specific errors (HTTP transport, XML/HTML
4//! parsing, database writes) into [`FetchError`] so that the orchestrator has a
5//! uniform error type to log and discard. Individual fetch failures are never
6//! fatal — they are logged as warnings and retried on the next poll interval.
7
8/// Errors that can occur during a Tier 1 fetch-and-store cycle.
9///
10/// Each variant wraps the underlying library error. The orchestrator logs these
11/// at `warn` level and continues polling; no variant is considered fatal.
12#[derive(Debug, thiserror::Error)]
13pub(crate) enum FetchError {
14    /// An HTTP request failed (connection refused, timeout, non-2xx status).
15    #[error("HTTP request failed: {0}")]
16    Http(#[from] reqwest::Error),
17
18    /// XML deserialization of the XLX API response failed.
19    #[error("XML parse error: {0}")]
20    Xml(#[from] quick_xml::DeError),
21
22    /// HTML scraping of the ircDDB last-heard page failed.
23    ///
24    /// This is a string-typed error because the `scraper` crate does not expose
25    /// a unified error type — parse failures surface as missing elements or
26    /// unexpected structure, which we describe as human-readable messages.
27    #[error("HTML scrape error: {0}")]
28    Html(String),
29
30    /// A database query or insert failed during the store phase.
31    #[error("database error: {0}")]
32    Database(#[from] sqlx::Error),
33}