From e24cd2a44d7fc6bbf2f1c0a0b1f14912945c3344 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=9B=E6=B0=B4=E5=B1=85=E5=AE=A4?= Date: Tue, 14 Mar 2023 10:40:27 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20incorrect=20handling=20of?= =?UTF-8?q?=20timeout=20exceptions=20in=20httpx?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/system/errorhandler.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/system/errorhandler.py b/plugins/system/errorhandler.py index f11053dc..6fbb1e5b 100644 --- a/plugins/system/errorhandler.py +++ b/plugins/system/errorhandler.py @@ -6,7 +6,7 @@ from typing import Optional import aiofiles from aiohttp import ClientError, ClientConnectorError from genshin import DataNotPublic, GenshinException, InvalidCookies, TooManyRequests -from httpx import Timeout as HttpxTimeout, HTTPError +from httpx import HTTPError, TimeoutException from telegram import ReplyKeyboardRemove, Update, InlineKeyboardMarkup, InlineKeyboardButton from telegram.constants import ParseMode from telegram.error import BadRequest, Forbidden, TelegramError, TimedOut, NetworkError @@ -184,8 +184,9 @@ class ErrorHandler(Plugin): return exc = context.error notice: Optional[str] = None - if isinstance(exc, HttpxTimeout): + if isinstance(exc, TimeoutException): notice = self.ERROR_MSG_PREFIX + " 连接连接服务器异常" + logger.warning("Httpx exception[%s]", str(exc)) if notice: self.create_notice_task(update, context, notice) raise ApplicationHandlerStop