Decorator error handling
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
from aiogram import types
|
||||
from bot.db import db, DBTables
|
||||
from bot.utils.cooldown import throttle
|
||||
from bot.keyboards.exception import get_exception_keyboard
|
||||
from bot.keyboards.image_info import get_img_info_keyboard
|
||||
from bot.utils.trace_exception import PrettyException
|
||||
from bot.utils.errorable_command import wrap_exception
|
||||
|
||||
|
||||
@wrap_exception([IndexError])
|
||||
@throttle(cooldown=10, admin_ids=db[DBTables.config].get('admins'))
|
||||
async def imginfo(message: types.Message):
|
||||
try:
|
||||
@@ -25,10 +25,3 @@ async def imginfo(message: types.Message):
|
||||
|
||||
except IndexError:
|
||||
await message.reply('❌ Reply with this command on PICTURE', parse_mode='html')
|
||||
|
||||
except Exception as e:
|
||||
exception_id = f'{message.message_thread_id}-{message.message_id}'
|
||||
db[DBTables.exceptions][exception_id] = PrettyException(e)
|
||||
await message.reply('❌ Error happened while processing your request', parse_mode='html',
|
||||
reply_markup=get_exception_keyboard(exception_id))
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user