1use std::fmt;
2
3use thiserror::Error;
4
5#[derive(Error, Debug)]
7pub enum Error {
8 #[error("failed to parse URL: {0}")]
10 ParseUrl(url::ParseError),
11
12 #[error("failed to send HTTP request: {0}")]
14 SendRequest(ReqwestDesensitizedError),
15
16 #[error("Telegram API error: {0:?}")]
18 TelegramApi(Option<String>),
19}
20
21pub type Result<T> = std::result::Result<T, Error>;
23
24#[derive(Debug)]
25pub struct ReqwestDesensitizedError(reqwest::Error);
26
27impl From<reqwest::Error> for ReqwestDesensitizedError {
28 fn from(value: reqwest::Error) -> Self {
29 Self(value.without_url())
30 }
31}
32
33impl fmt::Display for ReqwestDesensitizedError {
34 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
35 self.0.fmt(f)
36 }
37}