use std::io;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("http transport error: {0}")]
Http(#[from] reqwest::Error),
#[error("api error {code}: {message}")]
Api { code: i64, message: String },
#[error("auth error: {0}")]
Auth(String),
#[error("signing error: {0}")]
Signing(String),
#[error("decode error: {0}")]
Decode(#[from] serde_json::Error),
#[error("io error: {0}")]
Io(#[from] io::Error),
#[error("partial download: got {got} of {expected} bytes")]
Partial { got: u64, expected: u64 },
#[error("checksum mismatch for {file}: expected {expected}, got {got}")]
Checksum {
file: String,
expected: String,
got: String,
},
#[error("invalid url: {0}")]
Url(#[from] url::ParseError),
}
impl Error {
pub fn is_auth(&self) -> bool {
matches!(self, Error::Auth(_))
}
}