Skip to content

Commit

Permalink
upd: errors
Browse files Browse the repository at this point in the history
  • Loading branch information
likeinlife committed Feb 17, 2024
1 parent a5ba2b4 commit b78ad51
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/cartography/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ def __init__(self, info: Any) -> None:


class PartNomenclatureError(AdditionalInputMixin):
msg = "Invalid part"
msg = "Некорректная часть номенклатуры"


class InvalidLatitudeOrLongitude(AdditionalInputMixin):
msg = "Invalid latitude or longitude"
msg = "Некорректные координаты"


class NoLatitudeCharError(AdditionalInputMixin):
msg = "Invalid latitude char"
msg = "Некорректная широта"


class NoLongitudeIndexError(AdditionalInputMixin):
msg = "Invalid longitude index"
msg = "Некорректная долгота"


class InvalidNomenclatureTitleError(AdditionalInputMixin):
msg = "Invalid nomenclature part"
msg = "Некорректная номенклатура"
5 changes: 1 addition & 4 deletions src/tg_bot/handlers/nomenclature_title.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ async def nomenclature_title_handler(

images = NomenclatureFacade.generate_from_nomenclature(message.text)

media_group: list[InputMediaPhoto] = []
for image in images:
document = BufferedInputFile(image, "jpeg")
media_group.append(InputMediaPhoto(media=document))
media_group = [InputMediaPhoto(media=BufferedInputFile(image, "jpeg")) for image in images]

await message.answer_media_group(media_group) # type: ignore
await state.clear()
4 changes: 2 additions & 2 deletions src/tg_bot/middlewares.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ async def __call__(
logger.error(e.msg, username=event.from_user.username, chat_id=event.from_user.id)
await event.answer(e.msg)
if isinstance(event, Message):
logger.error(e.msg, username=event.from_user.username, chat_id=event.from_user.id) # type: ignore
logger.error(e.msg, username=event.chat.username, chat_id=event.chat.id)
await event.answer(e.msg)
except Exception as e:
if isinstance(event, CallbackQuery):
logger.error(e, username=event.from_user.username, chat_id=event.from_user.id, exc_info=True)
await event.answer("Unexpected error")
if isinstance(event, Message):
logger.error(e, username=event.from_user.username, chat_id=event.from_user.id, exc_info=True) # type: ignore
logger.error(e, username=event.chat.username, chat_id=event.chat.id, exc_info=True)
await event.answer("Unexpected error")

0 comments on commit b78ad51

Please sign in to comment.