From d0681c605b9709ece280fe41f193dd1210363827 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Wed, 13 Nov 2024 17:15:15 +0800 Subject: [PATCH] :bug: Fix handle PlaywrightTimeoutError --- plugins/system/errorhandler.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugins/system/errorhandler.py b/plugins/system/errorhandler.py index 3067839..6a6e180 100644 --- a/plugins/system/errorhandler.py +++ b/plugins/system/errorhandler.py @@ -6,6 +6,7 @@ from typing import Optional import aiofiles from httpx import HTTPError, TimeoutException +from playwright.async_api import Error as PlaywrightError, TimeoutError as PlaywrightTimeoutError from simnet.errors import ( DataNotPublic, BadRequest as SIMNetBadRequest, @@ -276,6 +277,15 @@ class ErrorHandler(Plugin): self.create_notice_task(update, context, config.notice.user_not_found) raise ApplicationHandlerStop + @error_handler() + async def process_playwright_exception(self, update: object, context: CallbackContext): + if not isinstance(context.error, PlaywrightError) or not isinstance(update, Update): + return + if isinstance(context.error, PlaywrightTimeoutError): + notice = self.ERROR_MSG_PREFIX + " 渲染超时 ~ 请稍后再试" + self.create_notice_task(update, context, notice) + raise ApplicationHandlerStop + @error_handler(block=False) async def process_z_error(self, update: object, context: CallbackContext) -> None: # 必须 `process_` 加上 `z` 保证该函数最后一个注册