use thiserror::Error;
#[derive(Debug, Error)]
pub enum BotError {
#[error("HTTP request failed: {0}")]
Http(#[from] reqwest::Error),
#[error("API returned error {err}: {msg}")]
Api {
err: i32,
msg: String,
},
#[error("API returned non-200 status {status}: {body}")]
Status {
status: u16,
body: String,
},
#[error("JSON parse failed: {0}")]
Json(#[from] serde_json::Error),
#[error("Redis error: {0}")]
Redis(#[from] redis::RedisError),
#[error("Not linked: run /link to connect your FicHub account")]
NotLinked,
#[error("Configuration error: {0}")]
Config(String),
#[error("Command error: {0}")]
Command(String),
#[error("Rate limited — retry in {retry_after_secs}s")]
RateLimited {
retry_after_secs: u64,
},
#[error("Internal error: {0}")]
Other(String),
}
pub type Result<T> = std::result::Result<T, BotError>;