use crate::{Capability, Protocol, Source};
#[non_exhaustive]
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("transient: {message}")]
Transient {
message: String,
retry_after: Option<std::time::Duration>,
},
#[error("permanent: {message}")]
Permanent {
message: String,
},
#[error("integrity: {message}")]
Integrity {
message: String,
},
#[error("absent price for asset: {asset}")]
AbsentPrice {
asset: String,
},
#[error("{protocol:?} does not support {capability:?} via {backend:?}")]
Unsupported {
protocol: Protocol,
capability: Capability,
backend: Source,
},
#[error("provider: {0}")]
Provider(#[source] Box<dyn std::error::Error + Send + Sync>),
}
impl Error {
#[must_use]
pub fn is_retryable(&self) -> bool {
matches!(self, Error::Transient { .. })
}
}