Skip to content

Commit

Permalink
try to fang error
Browse files Browse the repository at this point in the history
  • Loading branch information
pxp9 committed Aug 8, 2023
1 parent ecc37dd commit c344331
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 34 deletions.
57 changes: 33 additions & 24 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ chrono = "0.4"
diesel = { version = "2", features = ["postgres","r2d2"] }
dotenvy = "0.15"
pretty_env_logger = "0.5"
fang = { version = "0.10.3", features = ["blocking"], default-features = false }
#fang = { version = 10.3, features = ["blocking"], default-features = false }
fang = { git = "https://github.com/ayrat555/fang.git", branch = "ft/derive-macro-fang-error", features = ["blocking" , "derive-error"], default-features = false }
feed-rs = "1.3.0"
frankenstein = { version = "0.26.0", default-features = false, features = ["telegram-trait"] }
handlebars = "4"
Expand Down
12 changes: 3 additions & 9 deletions src/bot/telegram_client.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use crate::config::Config;
use crate::http_client;
use core::fmt::Debug;
use fang::FangError;
use fang::ToFangError;
use frankenstein::AllowedUpdate;
use frankenstein::DeleteMessageParams;
use frankenstein::ErrorResponse;
Expand Down Expand Up @@ -28,7 +30,7 @@ pub struct Api {
pub http_client: HttpClient,
}

#[derive(Debug)]
#[derive(Debug, ToFangError)]
pub enum Error {
HttpError(HttpError),
ApiError(ErrorResponse),
Expand All @@ -46,14 +48,6 @@ impl Default for Api {
}
}

impl From<Error> for FangError {
fn from(error: Error) -> Self {
let description = format!("telegram error: {error:?}");

Self { description }
}
}

#[derive(TypedBuilder)]
pub struct SimpleMessageParams {
chat_id: i64,
Expand Down

0 comments on commit c344331

Please sign in to comment.