Skip to main content

gor/
error.rs

1//! Error types for the `gor` library.
2//!
3//! Uses [`thiserror`] for ergonomic error definitions with proper
4//! `Display` and [`std::error::Error`] implementations.
5
6use thiserror::Error;
7
8/// Top-level error type for all `gor` operations.
9///
10/// Each variant corresponds to a distinct failure mode. Library code
11/// returns these errors; command code wraps them with [`anyhow`].
12#[derive(Error, Debug)]
13#[non_exhaustive]
14pub enum GorError {
15    /// An HTTP request to the GitHub API failed.
16    #[error("HTTP request failed: {0}")]
17    Http(#[from] reqwest::Error),
18
19    /// Authentication failed (invalid or expired token).
20    #[error("authentication failed: {0}")]
21    Auth(String),
22
23    /// The requested resource was not found (404).
24    #[error("not found: {0}")]
25    NotFound(String),
26
27    /// Rate limit exceeded (429 or secondary rate limit).
28    #[error("rate limit exceeded: {0}")]
29    RateLimit(String),
30
31    /// Invalid input from the user (bad repo spec, etc.).
32    #[error("invalid input: {0}")]
33    InvalidInput(String),
34
35    /// An I/O error occurred.
36    #[error("I/O error: {0}")]
37    Io(#[from] std::io::Error),
38
39    /// A keyring operation failed.
40    #[error("keyring error: {0}")]
41    Keyring(String),
42
43    /// The OAuth device flow timed out waiting for user authorization.
44    #[error("device flow timed out: {0}")]
45    DeviceTimeout(String),
46
47    /// The OAuth device flow was declined by the user.
48    #[error("device flow authorization declined")]
49    DeviceDeclined,
50}