use thiserror::Error;
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum Error {
#[error("invalid URL: {0}")]
InvalidUrl(#[from] url::ParseError),
#[error("requested NodeInfo version {requested} not advertised by server")]
VersionNotAdvertised {
requested: &'static str,
},
#[cfg(feature = "client")]
#[cfg_attr(docsrs, doc(cfg(feature = "client")))]
#[error("HTTP error: {0}")]
Http(#[from] reqwest::Error),
#[cfg(feature = "client")]
#[cfg_attr(docsrs, doc(cfg(feature = "client")))]
#[error("NodeInfo server returned status {0}")]
BadStatus(u16),
#[cfg(feature = "client")]
#[cfg_attr(docsrs, doc(cfg(feature = "client")))]
#[error("NodeInfo response body exceeds the {0}-byte limit")]
ResponseTooLarge(u64),
#[error("JSON error: {0}")]
Json(#[from] serde_json::Error),
#[cfg(feature = "client")]
#[cfg_attr(docsrs, doc(cfg(feature = "client")))]
#[error(
"NodeInfo discovery at `{discovery}` advertised a cross-origin href `{href}`; \
refusing to follow"
)]
CrossOriginHref {
discovery: url::Url,
href: url::Url,
},
}