1use thiserror::Error;
2
3pub type TelegramResult<T> = std::result::Result<T, TelegramError>;
5
6#[derive(Debug, Error)]
8pub enum TelegramError {
9 #[error(
11 "telegram bot token not found: set RALPH_TELEGRAM_BOT_TOKEN or configure human.telegram.bot_token"
12 )]
13 MissingBotToken,
14
15 #[error("failed to start telegram bot: {0}")]
17 Startup(String),
18
19 #[error("failed to send telegram message after {attempts} attempts: {reason}")]
21 Send { attempts: u32, reason: String },
22
23 #[error("failed to receive telegram messages: {0}")]
25 Receive(String),
26
27 #[error("timed out waiting for human response after {timeout_secs}s")]
29 ResponseTimeout { timeout_secs: u64 },
30
31 #[error("state persistence error: {0}")]
33 State(#[from] std::io::Error),
34
35 #[error("state parse error: {0}")]
37 StateParse(#[from] serde_json::Error),
38
39 #[error("event write error: {0}")]
41 EventWrite(String),
42}