Skip to content

Commit

Permalink
🐛 Fix handle PlaywrightTimeoutError
Browse files Browse the repository at this point in the history
  • Loading branch information
omg-xtao committed Nov 13, 2024
1 parent e1becdf commit d0681c6
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions plugins/system/errorhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

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,
Expand Down Expand Up @@ -276,6 +277,15 @@ async def process_public_cookies(self, update: object, context: CallbackContext)
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` 保证该函数最后一个注册
Expand Down

0 comments on commit d0681c6

Please sign in to comment.