pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("base64 decode error: {0}")]
Base64Decode(#[from] base64ct::Error),
#[error("Backpack API error: {status_code}: {message}")]
BpxApiError {
status_code: reqwest::StatusCode,
message: Box<str>,
},
#[error(transparent)]
InvalidHeaderValue(#[from] reqwest::header::InvalidHeaderValue),
#[error("Invalid request: {0}")]
InvalidRequest(Box<str>),
#[error("Client is not authenticated")]
NotAuthenticated,
#[error(transparent)]
Reqwest(#[from] reqwest::Error),
#[error("Invalid secret key")]
SecretKey,
#[error(transparent)]
SerdeJson(#[from] serde_json::error::Error),
#[error(transparent)]
SystemTime(#[from] std::time::SystemTimeError),
#[error(transparent)]
Utf8(#[from] std::str::Utf8Error),
#[error("Invalid URL: {0}")]
UrlParseError(Box<str>),
}
impl From<url::ParseError> for Error {
fn from(e: url::ParseError) -> Self {
Error::UrlParseError(e.to_string().into_boxed_str())
}
}