1use std::fmt;
2
3#[derive(Debug)]
5pub enum Error {
6 Authentication(String),
8 Network(String),
10 Api(u16, String),
12 Parse(String),
14 Validation(String),
16}
17
18impl fmt::Display for Error {
19 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
20 match self {
21 Error::Authentication(msg) => write!(f, "Authentication error: {}", msg),
22 Error::Network(msg) => write!(f, "Network error: {}", msg),
23 Error::Api(code, msg) => write!(f, "API error ({}): {}", code, msg),
24 Error::Parse(msg) => write!(f, "Parse error: {}", msg),
25 Error::Validation(msg) => write!(f, "Validation error: {}", msg),
26 }
27 }
28}
29
30impl std::error::Error for Error {}
31
32pub type Result<T> = std::result::Result<T, Error>;