instapi360_cloud/
error.rs1use std::io;
4
5pub type Result<T> = std::result::Result<T, Error>;
7
8#[derive(Debug, thiserror::Error)]
10pub enum Error {
11 #[error("http transport error: {0}")]
13 Http(#[from] reqwest::Error),
14
15 #[error("api error {code}: {message}")]
17 Api { code: i64, message: String },
18
19 #[error("auth error: {0}")]
21 Auth(String),
22
23 #[error("signing error: {0}")]
25 Signing(String),
26
27 #[error("decode error: {0}")]
29 Decode(#[from] serde_json::Error),
30
31 #[error("io error: {0}")]
33 Io(#[from] io::Error),
34
35 #[error("partial download: got {got} of {expected} bytes")]
37 Partial { got: u64, expected: u64 },
38
39 #[error("checksum mismatch for {file}: expected {expected}, got {got}")]
41 Checksum {
42 file: String,
43 expected: String,
44 got: String,
45 },
46
47 #[error("invalid url: {0}")]
49 Url(#[from] url::ParseError),
50}
51
52impl Error {
53 pub fn is_auth(&self) -> bool {
55 matches!(self, Error::Auth(_))
56 }
57}