use std::fmt;
#[derive(Debug)]
pub enum WOWSQLError {
Authentication(String),
NotFound(String),
RateLimit(String),
Network(String),
Storage(String),
StorageLimitExceeded {
message: String,
required_bytes: i64,
available_bytes: i64,
},
PermissionDenied(String),
RequestFailed(String),
General(String),
}
impl fmt::Display for WOWSQLError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
WOWSQLError::Authentication(msg) => write!(f, "Authentication error: {}", msg),
WOWSQLError::NotFound(msg) => write!(f, "Not found: {}", msg),
WOWSQLError::RateLimit(msg) => write!(f, "Rate limit exceeded: {}", msg),
WOWSQLError::Network(msg) => write!(f, "Network error: {}", msg),
WOWSQLError::Storage(msg) => write!(f, "Storage error: {}", msg),
WOWSQLError::StorageLimitExceeded { message, .. } => {
write!(f, "Storage limit exceeded: {}", message)
}
WOWSQLError::PermissionDenied(msg) => write!(f, "Permission denied: {}", msg),
WOWSQLError::RequestFailed(msg) => write!(f, "Request failed: {}", msg),
WOWSQLError::General(msg) => write!(f, "Error: {}", msg),
}
}
}
impl std::error::Error for WOWSQLError {}
impl From<reqwest::Error> for WOWSQLError {
fn from(err: reqwest::Error) -> Self {
WOWSQLError::Network(err.to_string())
}
}