From 63c75307e336099bd4efe2b2b7b10c8694a51820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=9B=E6=B0=B4=E5=B1=85=E5=AE=A4?= Date: Thu, 16 Mar 2023 23:18:39 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Update=20Exception=20Handler?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/system/errorhandler.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/system/errorhandler.py b/plugins/system/errorhandler.py index ab14c970..ed7161e2 100644 --- a/plugins/system/errorhandler.py +++ b/plugins/system/errorhandler.py @@ -139,7 +139,8 @@ class ErrorHandler(Plugin): return notice: Optional[str] = None if isinstance(context.error, TimedOut): - notice = self.ERROR_MSG_PREFIX + " 连接连接服务器异常" + # notice = self.ERROR_MSG_PREFIX + " 连接 telegram 服务器超时" + logger.error("连接 telegram 服务器超时 [%s]", repr(context.error)) elif isinstance(context.error, BadRequest): if "Replied message not found" in context.error.message: notice = "气死我了!怎么有人喜欢发一个命令就秒删了!" @@ -173,7 +174,7 @@ class ErrorHandler(Plugin): exc = context.error notice: Optional[str] = None if isinstance(exc, APIHelperTimedOut): - notice = self.ERROR_MSG_PREFIX + " 连接连接服务器异常" + notice = self.ERROR_MSG_PREFIX + " 服务器熟啦 ~ 请稍后再试" elif isinstance(exc, ReturnCodeError): notice = self.ERROR_MSG_PREFIX + f"API请求错误 错误信息为 {exc.message if exc.message else exc.code} ~ 请稍后再试" elif isinstance(exc, ResponseException): @@ -189,7 +190,7 @@ class ErrorHandler(Plugin): exc = context.error notice: Optional[str] = None if isinstance(exc, TimeoutException): - notice = self.ERROR_MSG_PREFIX + " 连接连接服务器异常" + notice = self.ERROR_MSG_PREFIX + " 服务器熟啦 ~ 请稍后再试" logger.warning("Httpx exception[%s]", str(exc)) if notice: self.create_notice_task(update, context, notice) @@ -202,9 +203,9 @@ class ErrorHandler(Plugin): exc = context.error notice: Optional[str] = None if isinstance(exc, AioHttpTimeoutException): - notice = self.ERROR_MSG_PREFIX + " 连接连接服务器异常" + notice = self.ERROR_MSG_PREFIX + " 服务器熟啦 ~ 请稍后再试" elif isinstance(exc, ClientConnectorError): - notice = self.ERROR_MSG_PREFIX + " 连接连接服务器异常" + notice = self.ERROR_MSG_PREFIX + " 连接服务器异常" if notice: self.create_notice_task(update, context, notice) raise ApplicationHandlerStop