Update error_handler.py

This commit is contained in:
Kostiantyn Kriuchkov 2021-10-05 17:51:35 +03:00 committed by GitHub
parent 364e4506ec
commit 202e90e086
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,17 +20,21 @@ async def errors_handler(update, exception):
if isinstance(exception, CantDemoteChatCreator): if isinstance(exception, CantDemoteChatCreator):
logging.exception("Can't demote chat creator") logging.exception("Can't demote chat creator")
# do something here?
return True return True
if isinstance(exception, MessageNotModified): if isinstance(exception, MessageNotModified):
logging.exception('Message is not modified') logging.exception('Message is not modified')
# or here
return True return True
if isinstance(exception, MessageCantBeDeleted): if isinstance(exception, MessageCantBeDeleted):
logging.exception('Message cant be deleted') logging.exception('Message cant be deleted')
# or here
return True return True
if isinstance(exception, MessageToDeleteNotFound): if isinstance(exception, MessageToDeleteNotFound):
logging.exception('Message to delete not found') logging.exception('Message to delete not found')
# well, you know.
return True return True
if isinstance(exception, MessageTextIsEmpty): if isinstance(exception, MessageTextIsEmpty):
@ -45,14 +49,18 @@ async def errors_handler(update, exception):
logging.exception(f'InvalidQueryID: {exception} \nUpdate: {update}') logging.exception(f'InvalidQueryID: {exception} \nUpdate: {update}')
return True return True
if isinstance(exception, TelegramAPIError):
logging.exception(f'TelegramAPIError: {exception} \nUpdate: {update}')
return True
if isinstance(exception, RetryAfter): if isinstance(exception, RetryAfter):
logging.exception(f'RetryAfter: {exception} \nUpdate: {update}') logging.exception(f'RetryAfter: {exception} \nUpdate: {update}')
return True return True
if isinstance(exception, CantParseEntities): if isinstance(exception, CantParseEntities):
logging.exception(f'CantParseEntities: {exception} \nUpdate: {update}') logging.exception(f'CantParseEntities: {exception} \nUpdate: {update}')
return True return True
# MUST BE THE LAST CONDITION (ЭТО УСЛОВИЕ ВСЕГДА ДОЛЖНО БЫТЬ В КОНЦЕ)
if isinstance(exception, TelegramAPIError):
logging.exception(f'TelegramAPIError: {exception} \nUpdate: {update}')
return True
# At least you have tried.
logging.exception(f'Update: {update} \n{exception}') logging.exception(f'Update: {update} \n{exception}')