mirror of
https://github.com/PaiGramTeam/PaiGram.git
synced 2024-11-22 07:07:46 +00:00
🎨 Handle NetworkError and TimedOut exceptions separately
This commit is contained in:
parent
4d67904118
commit
da0faf6d98
@ -6,7 +6,7 @@ import traceback
|
||||
import aiofiles
|
||||
from telegram import ReplyKeyboardRemove, Update
|
||||
from telegram.constants import ParseMode
|
||||
from telegram.error import BadRequest, Forbidden
|
||||
from telegram.error import BadRequest, Forbidden, NetworkError, TimedOut
|
||||
from telegram.ext import CallbackContext
|
||||
|
||||
from core.bot import bot
|
||||
@ -32,6 +32,13 @@ class ErrorHandler(Plugin):
|
||||
async def error_handler(self, update: object, context: CallbackContext) -> None:
|
||||
"""记录错误并发送消息通知开发人员。 logger the error and send a telegram message to notify the developer."""
|
||||
|
||||
if isinstance(NetworkError, context.error):
|
||||
logger.error("Bot请求异常", exc_info=context.error)
|
||||
return
|
||||
if isinstance(TimedOut, context.error):
|
||||
logger.error("Bot请求超时", exc_info=context.error)
|
||||
return
|
||||
|
||||
logger.error("处理函数时发生异常")
|
||||
logger.exception(context.error, exc_info=(type(context.error), context.error, context.error.__traceback__))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user