use alloy_primitives::{ChainId, private::serde::de::StdError};
pub(crate) type BoxError = Box<dyn StdError + Send + Sync>;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("HTTP error: {0}")]
Http(BoxError),
#[error("URL parse error: {0}")]
Url(#[from] url::ParseError),
#[error("Time error: {0}")]
Jiff(#[from] jiff::Error),
#[error("uts decoding error: {0}")]
Decode(#[from] uts_core::error::DecodeError),
#[error("uts encoding error: {0}")]
Encode(#[from] uts_core::error::EncodeError),
#[error(transparent)]
Finalization(#[from] uts_core::codec::v1::FinalizationError),
#[error("Input cannot be empty")]
EmptyInput,
#[error("Quorum of {required} not reached, only {received} responses received")]
QuorumNotReached {
required: usize,
received: usize,
},
#[error("Digest mismatch: expected {expected:?}, got {actual:?}")]
DigestMismatch {
expected: Box<[u8]>,
actual: Box<[u8]>,
},
#[error("Unsupported feature: {0}")]
Unsupported(&'static str),
#[error("Unsupported chain ID: {0}")]
UnsupportedChain(ChainId),
}
impl From<reqwest::Error> for Error {
fn from(value: reqwest::Error) -> Self {
Self::Http(Box::new(value))
}
}
impl From<http::Error> for Error {
fn from(value: http::Error) -> Self {
Self::Http(Box::new(value))
}
}