Skip to main content

rung_github/
error.rs

1//! Error types for rung-github.
2
3/// Result type alias using [`Error`].
4pub type Result<T> = std::result::Result<T, Error>;
5
6/// Errors that can occur during GitHub API operations.
7#[derive(Debug, thiserror::Error)]
8pub enum Error {
9    /// Authentication failed or token missing.
10    #[error("GitHub authentication failed - run `gh auth login` or set GITHUB_TOKEN")]
11    AuthenticationFailed,
12
13    /// Token not found.
14    #[error("no GitHub token found - run `gh auth login` or set GITHUB_TOKEN")]
15    NoToken,
16
17    /// API rate limit exceeded.
18    #[error("GitHub API rate limit exceeded - wait and try again")]
19    RateLimited,
20
21    /// Repository not found or no access.
22    #[error("repository not found or no access: {0}")]
23    RepoNotFound(String),
24
25    /// PR not found.
26    #[error("pull request not found: #{0}")]
27    PrNotFound(u64),
28
29    /// API error with status code.
30    #[error("GitHub API error ({status}): {message}")]
31    ApiError { status: u16, message: String },
32
33    /// Network error.
34    #[error("network error: {0}")]
35    Network(#[from] reqwest::Error),
36
37    /// JSON parsing error.
38    #[error("failed to parse GitHub response: {0}")]
39    Parse(#[from] serde_json::Error),
40
41    /// IO error (e.g., reading gh CLI token).
42    #[error("io error: {0}")]
43    Io(#[from] std::io::Error),
44}