-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
11 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,30 @@ | ||
import logging | ||
from typing import Optional | ||
|
||
from aiogram.utils.exceptions import (TelegramAPIError, | ||
MessageNotModified, | ||
CantParseEntities) | ||
from loguru import logger | ||
|
||
from loader import dp | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
@dp.errors_handler() | ||
async def errors_handler(update, exception) -> Optional[bool]: | ||
if isinstance(exception, MessageNotModified): | ||
logger.exception('Message is not modified') | ||
logger.error('Message is not modified') | ||
# do something here? | ||
return True | ||
|
||
if isinstance(exception, CantParseEntities): | ||
# or here | ||
logger.exception(f'CantParseEntities: {exception} \nUpdate: {update}') | ||
logger.error(f'CantParseEntities: {exception} \nUpdate: {update}') | ||
return True | ||
|
||
# MUST BE THE LAST CONDITION | ||
if isinstance(exception, TelegramAPIError): | ||
logger.exception(f'TelegramAPIError: {exception} \nUpdate: {update}') | ||
logger.error(f'TelegramAPIError: {exception} \nUpdate: {update}') | ||
return True | ||
|
||
# At least you have tried. | ||
logger.exception(f'Update: {update} \n{exception}') | ||
logger.error(f'Update: {update} \n{exception}') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters