Skip to main content

telegram_rs_2/
errors.rs

1use thiserror::Error;
2
3/// A specialized Result type for telegram-rs operations
4pub type Result<T> = std::result::Result<T, Error>;
5
6/// Represents errors that can occur during telegram-rs operations
7#[derive(Debug, Error)]
8pub enum Error {
9    #[error("Network error: {0}")]
10    Network(#[from] reqwest::Error),
11
12    #[error("Serialization error: {0}")]
13    Serialization(#[from] serde_json::Error),
14
15    #[error("Telegram API error: {description} (error_code: {error_code:?})")]
16    Api {
17        error_code: Option<i32>,
18        description: String,
19    },
20
21    #[error("Invalid configuration: {0}")]
22    InvalidConfig(String),
23
24    #[error("Other error: {0}")]
25    Other(String),
26}
27