use std::fmt::{Display, Error, Formatter};
use reqwest::{multipart, StatusCode};
#[derive(Debug)]
pub struct ErrorResult {
pub code: u16, pub msg: String, }
#[derive(Debug, serde::Deserialize)]
pub struct TelegramErrorResult {
pub ok: bool,
pub error_code: i32,
pub description: String,
}
impl Display for ErrorResult {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
write!(f, "{}", self.msg)
}
}
impl From<std::io::Error> for ErrorResult {
fn from(err: std::io::Error) -> Self {
ErrorResult {
code: StatusCode::INTERNAL_SERVER_ERROR.as_u16(),
msg: format!("IO Error: {}", err),
}
}
}
impl From<reqwest::Error> for ErrorResult {
fn from(err: reqwest::Error) -> Self {
ErrorResult {
code: StatusCode::INTERNAL_SERVER_ERROR.as_u16(),
msg: format!("HTTP Request Error: {}", err),
}
}
}