From 91f8eb6acc1e43c1c988f0c3b7f8a4ebfb56f28a Mon Sep 17 00:00:00 2001 From: Hirrolot Date: Mon, 21 Mar 2022 20:40:04 +0600 Subject: [PATCH] Log `UpdateKind::Error` in `dispatching2` --- CHANGELOG.md | 4 ++++ src/dispatching2/dispatcher.rs | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b3cc0a2..612ecde7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - The `Storage::erase` default function that returns `ErasedStorage`. - `ErasedStorage`, a storage with an erased error type. +### Fixed + +- Log `UpdateKind::Error` in `teloxide::dispatching2::Dispatcher`. + ## 0.7.1 - 2022-03-09 ### Fixed diff --git a/src/dispatching2/dispatcher.rs b/src/dispatching2/dispatcher.rs index 9f1add78..56d7699f 100644 --- a/src/dispatching2/dispatcher.rs +++ b/src/dispatching2/dispatcher.rs @@ -11,7 +11,10 @@ use crate::{ use dptree::di::{DependencyMap, DependencySupplier}; use futures::{future::BoxFuture, StreamExt}; use std::{collections::HashSet, fmt::Debug, ops::ControlFlow, sync::Arc}; -use teloxide_core::requests::{Request, RequesterExt}; +use teloxide_core::{ + requests::{Request, RequesterExt}, + types::UpdateKind, +}; use tokio::time::timeout; use std::future::Future; @@ -217,6 +220,16 @@ where { match update { Ok(upd) => { + if let UpdateKind::Error(err) = upd.kind { + log::error!( + "Cannot parse an update.\nError: {:?}\n\ + This is a bug in teloxide-core, please open an issue here: \ + https://github.com/teloxide/teloxide-core/issues.", + err, + ); + return; + } + let mut deps = self.dependencies.clone(); deps.insert(upd); deps.insert(self.bot.clone());