Add inline error info
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
from bot.common import console
|
||||
from aiogram.types.error_event import ErrorEvent
|
||||
from aiogram import Bot
|
||||
from aiogram.dispatcher import router as s_router
|
||||
|
||||
from rich.traceback import Traceback
|
||||
from .pretty import PrettyException
|
||||
|
||||
from bot.modules.database import db
|
||||
|
||||
@@ -11,6 +13,7 @@ from dataclasses import dataclass
|
||||
|
||||
@dataclass
|
||||
class Error:
|
||||
exception: PrettyException
|
||||
traceback: Traceback
|
||||
inline_message_id: str | None = None
|
||||
|
||||
@@ -26,12 +29,14 @@ async def on_error(event: ErrorEvent, bot: Bot):
|
||||
event.exception,
|
||||
event.exception.__traceback__,
|
||||
show_locals=True,
|
||||
max_frames=1,
|
||||
suppress=[s_router],
|
||||
)
|
||||
pretty_exception = PrettyException(event.exception)
|
||||
|
||||
if event.update.chosen_inline_result:
|
||||
db.errors[error_id] = Error(
|
||||
traceback=traceback,
|
||||
exception=pretty_exception,
|
||||
inline_message_id=event.update.chosen_inline_result.inline_message_id,
|
||||
)
|
||||
|
||||
@@ -45,9 +50,10 @@ async def on_error(event: ErrorEvent, bot: Bot):
|
||||
else:
|
||||
db.errors[error_id] = Error(
|
||||
traceback=traceback,
|
||||
exception=pretty_exception,
|
||||
)
|
||||
|
||||
console.print(f'[red]{error_id} occurred[/]')
|
||||
console.print(event)
|
||||
console.print(traceback)
|
||||
console.print(f'-{error_id}-')
|
||||
console.print(f'-{error_id} occurred-')
|
||||
|
||||
Reference in New Issue
Block a user