Skip to main content

tga_collect/
errors.rs

1//! Error types for the `tga-collect` crate.
2//!
3//! `CollectError` aggregates failures from git operations, HTTP requests,
4//! the core database layer, and identity resolution. As a library crate,
5//! we use [`thiserror`] for structured errors that callers can match on.
6
7use thiserror::Error;
8
9/// Top-level error type for collection-stage operations.
10#[derive(Debug, Error)]
11pub enum CollectError {
12    /// A `git2`/libgit2 error occurred during repository operations.
13    #[error("git error: {0}")]
14    Git(#[from] git2::Error),
15
16    /// An HTTP transport or response error occurred.
17    #[error("HTTP error: {0}")]
18    Http(#[from] reqwest::Error),
19
20    /// A core error bubbled up from `tga-core` (DB, config, validation).
21    #[error("core error: {0}")]
22    Core(#[from] tga_core::TgaError),
23
24    /// A direct `rusqlite` error from inline SQL in this crate.
25    #[error("database error: {0}")]
26    Db(#[from] rusqlite::Error),
27
28    /// Identity resolution failed for the given context.
29    #[error("identity resolution failed: {0}")]
30    Identity(String),
31
32    /// An underlying `std::io` error (file not found, permission denied, etc.).
33    #[error("I/O error: {0}")]
34    Io(#[from] std::io::Error),
35
36    /// JSON serialization/deserialization failure.
37    #[error("JSON error: {0}")]
38    Json(#[from] serde_json::Error),
39
40    /// A configuration value required for this operation was missing.
41    #[error("configuration error: {0}")]
42    Config(String),
43}
44
45/// Crate-wide `Result` alias.
46pub type Result<T> = std::result::Result<T, CollectError>;