Skip to main content

rustigram_bot/
error.rs

1use thiserror::Error;
2
3/// Top-level error type for the bot framework layer.
4#[derive(Debug, Error)]
5pub enum BotError {
6    /// Propagated from the API layer.
7    #[error("API error: {0}")]
8    Api(#[from] rustigram_api::Error),
9
10    /// Handler returned an error.
11    #[error("Handler error: {0}")]
12    Handler(#[from] anyhow::Error),
13
14    /// I/O error (e.g. while binding the webhook server).
15    #[error("I/O error: {0}")]
16    Io(#[from] std::io::Error),
17
18    /// The dispatcher was shut down.
19    #[error("Dispatcher shut down")]
20    Shutdown,
21}
22
23/// A specialised `Result` type for rustigram bot operations.
24pub type BotResult<T> = std::result::Result<T, BotError>;