use std::fmt;
#[derive(Debug)]
pub enum Error {
Authentication(String),
Network(String),
Api(u16, String),
Parse(String),
Validation(String),
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Error::Authentication(msg) => write!(f, "Authentication error: {}", msg),
Error::Network(msg) => write!(f, "Network error: {}", msg),
Error::Api(code, msg) => write!(f, "API error ({}): {}", code, msg),
Error::Parse(msg) => write!(f, "Parse error: {}", msg),
Error::Validation(msg) => write!(f, "Validation error: {}", msg),
}
}
}
impl std::error::Error for Error {}
pub type Result<T> = std::result::Result<T, Error>;