1use thiserror::Error;
4
5#[derive(Debug, Error)]
7pub enum BotError {
8 #[error("HTTP request failed: {0}")]
10 Http(#[from] reqwest::Error),
11 #[error("API returned error {err}: {msg}")]
13 Api {
14 err: i32,
16 msg: String,
18 },
19 #[error("API returned non-200 status {status}: {body}")]
21 Status {
22 status: u16,
24 body: String,
26 },
27 #[error("JSON parse failed: {0}")]
29 Json(#[from] serde_json::Error),
30 #[error("Redis error: {0}")]
32 Redis(#[from] redis::RedisError),
33 #[error("Not linked: run /link to connect your FicHub account")]
35 NotLinked,
36 #[error("Configuration error: {0}")]
38 Config(String),
39 #[error("Command error: {0}")]
41 Command(String),
42 #[error("Rate limited — retry in {retry_after_secs}s")]
44 RateLimited {
45 retry_after_secs: u64,
47 },
48 #[error("Internal error: {0}")]
50 Other(String),
51}
52
53pub type Result<T> = std::result::Result<T, BotError>;