gha_toolkit/
result.rs

1pub type Result<T, E = Error> = std::result::Result<T, E>;
2
3#[derive(thiserror::Error, Debug)]
4#[non_exhaustive]
5pub enum Error {
6    #[error("Invalid chunk checksum")]
7    CacheChunkChecksum,
8
9    #[error("While {message}: expected chunk size {expected_size} got {actual_size}")]
10    CacheChunkSize {
11        expected_size: usize,
12        actual_size: usize,
13        message: &'static str,
14    },
15
16    #[error("Cache not found.")]
17    CacheNotFound,
18
19    #[error("Cache service responded with {status}: {message}")]
20    CacheServiceStatus {
21        status: http::StatusCode,
22        message: String,
23    },
24
25    #[error("Cache size of {0} bytes is too large")]
26    CacheSizeTooLarge(usize),
27
28    #[error(transparent)]
29    InvalidHeaderValue(#[from] http::header::InvalidHeaderValue),
30
31    #[error("Key Validation Error: {0} cannot contain commas")]
32    InvalidKeyComma(String),
33
34    #[error("Key Validation Error: {0} cannot be larger than 512 characters")]
35    InvalidKeyLength(String),
36
37    #[error("Missing one of key or restore keys")]
38    MissingKey,
39
40    #[error(transparent)]
41    IO(#[from] std::io::Error),
42
43    #[error(transparent)]
44    Reqwest(#[from] reqwest::Error),
45
46    #[error(transparent)]
47    ReqwestMiddleware(#[from] reqwest_middleware::Error),
48
49    #[error(transparent)]
50    SerdeJson(#[from] serde_json::Error),
51
52    #[error(transparent)]
53    SerdeUrlencodedSerialize(#[from] serde_urlencoded::ser::Error),
54
55    #[error(transparent)]
56    UrlParse(#[from] url::ParseError),
57
58    #[error("Error reading env var \"{name}\": {source} ")]
59    VarError {
60        #[source]
61        source: std::env::VarError,
62        name: &'static str,
63    },
64}