use thiserror::Error;
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum CollectError {
#[error("git error: {0}")]
Git(#[from] git2::Error),
#[error("HTTP error: {0}")]
Http(#[from] reqwest::Error),
#[error("core error: {0}")]
Core(#[from] crate::core::TgaError),
#[error("database error: {0}")]
Db(#[from] rusqlite::Error),
#[error("identity resolution failed: {0}")]
Identity(String),
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("JSON error: {0}")]
Json(#[from] serde_json::Error),
#[error("configuration error: {0}")]
Config(String),
#[error("GitHub API error (HTTP {status}) for {endpoint}: {message}")]
GithubApi {
status: u16,
endpoint: String,
message: String,
},
#[error(
"GitHub issue search for `{query}` is inconclusive: {scanned} of {total} \
match(es) were read within the paging budget, so an existing thread may \
have been missed; refusing to create a possible duplicate"
)]
GithubSearchInconclusive {
query: String,
scanned: usize,
total: u64,
},
#[error(
"incomplete JIRA changelog for {key}: JIRA reported {expected} history \
entries but only {retrieved} could be retrieved"
)]
IncompleteChangelog {
key: String,
expected: u64,
retrieved: u64,
},
#[error(
"JIRA {endpoint} paging for {key} did not terminate within {pages} pages; \
the server is not honouring `startAt`"
)]
PagingBudgetExceeded {
endpoint: &'static str,
key: String,
pages: usize,
},
#[error("Linear API error (HTTP {status}) for {identifier}: {message}")]
LinearApi {
status: u16,
identifier: String,
message: String,
},
#[error("throttled by remote (HTTP {status}){}", match retry_after {
Some(d) => format!("; Retry-After: {}s", d.as_secs()),
None => String::new(),
})]
Throttled {
status: u16,
retry_after: Option<std::time::Duration>,
},
}
pub type Result<T> = std::result::Result<T, CollectError>;