use std::fmt;
/// Error types for the generated SDK.
#[derive(Debug)]
pub enum Error {
/// HTTP/transport error from aioduct.
Http(aioduct::Error),
/// JSON deserialization error.
Deserialize(serde_json::Error),
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Error::Http(e) => write!(f, "HTTP error: {e}"),
Error::Deserialize(e) => write!(f, "Deserialization error: {e}"),
}
}
}
impl std::error::Error for Error {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
Error::Http(e) => Some(e),
Error::Deserialize(e) => Some(e),
}
}
}
impl From<aioduct::Error> for Error {
fn from(e: aioduct::Error) -> Self {
Error::Http(e)
}
}
impl From<serde_json::Error> for Error {
fn from(e: serde_json::Error) -> Self {
Error::Deserialize(e)
}
}