git_bot_feedback/
error.rs

1//! Error types used across the git-bot-feedback crate.
2use thiserror::Error;
3
4use crate::OutputVariable;
5
6/// The possible error emitted by the REST client API
7#[derive(Debug, Error)]
8pub enum RestClientError {
9    /// Error related to making HTTP requests
10    #[error("{0}")]
11    Request(#[from] reqwest::Error),
12
13    /// Errors related to standard I/O.
14    #[error("{0}")]
15    Io(#[from] std::io::Error),
16
17    /// Error related to Git command execution
18    #[error("Git command error: {0}")]
19    #[cfg(feature = "file-changes")]
20    #[cfg_attr(docsrs, doc(cfg(feature = "file-changes")))]
21    GitCommandError(String),
22
23    /// Error related to exceeding REST API Rate limits
24    #[error("Rate Limit exceeded")]
25    RateLimit,
26
27    /// Error emitted when cloning a request object fails.
28    #[error("Failed to clone request object for auto-reties")]
29    RequestCloneError,
30
31    /// Error emitted when creating header value fails.
32    #[error("Tried to create a header value from invalid string data")]
33    InvalidHeaderValue(#[from] reqwest::header::InvalidHeaderValue),
34
35    /// Error emitted when parsing a URL fails.
36    #[error("{0}")]
37    UrlParseError(#[from] url::ParseError),
38
39    /// Error emitted when deserializing/serializing request/response JSON data.
40    #[error("{0}")]
41    JsonError(#[from] serde_json::Error),
42
43    /// Error emitted when failing to read environment variable
44    #[error("{0}")]
45    EnvVarError(#[from] std::env::VarError),
46
47    /// An error emitted when encountering an invalid [`OutputVariable`].
48    #[error("OutputVariable is malformed: {0}")]
49    OutputVarError(OutputVariable),
50}
51
52/// The possible errors emitted by file utilities
53#[cfg(feature = "file-changes")]
54#[derive(Debug, Error)]
55#[cfg_attr(docsrs, doc(cfg(feature = "file-changes")))]
56pub enum DirWalkError {
57    #[error("Failed to read directory {0}: {1}")]
58    ReadDirError(String, std::io::Error),
59}