use std::borrow::Cow;
#[derive(Debug, thiserror::Error)]
pub enum PolyrelError {
#[error("http error: {0}")]
Http(Cow<'static, str>),
#[error("api error {status}: {body}")]
Api {
status: u16,
body: Cow<'static, str>,
},
#[error("rate limit error")]
RateLimited,
#[error("deserialize error: {0}")]
Deserialize(Cow<'static, str>),
#[error("signing error: {0}")]
Signing(Cow<'static, str>),
#[error("invalid signature error: {0}")]
InvalidSignature(Cow<'static, str>),
#[error("invalid numeric field {field}: {value}")]
InvalidNumericField {
field: &'static str,
value: Cow<'static, str>,
},
#[error("invalid auth header {header}: {detail}")]
InvalidAuthHeader {
header: &'static str,
detail: Cow<'static, str>,
},
#[error("empty transaction batch error")]
EmptyBatch,
#[error("safe already deployed error")]
SafeAlreadyDeployed,
}
impl From<reqwest::Error> for PolyrelError {
fn from(err: reqwest::Error) -> Self {
Self::Http(Cow::Owned(err.to_string()))
}
}
impl From<serde_json::Error> for PolyrelError {
fn from(err: serde_json::Error) -> Self {
Self::Deserialize(Cow::Owned(err.to_string()))
}
}