Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle exception, when caption too long #59

Open
Salz0 opened this issue Nov 6, 2023 · 0 comments
Open

Handle exception, when caption too long #59

Salz0 opened this issue Nov 6, 2023 · 0 comments
Labels
bug Something isn't working good first issue Good for newcomers hacktoberfest

Comments

@Salz0
Copy link
Owner

Salz0 commented Nov 6, 2023

The user should be notified that this length has a constraint, let it be around 2k symbols

Looks something like this:

2023-11-06T13:06:08.294794+00:00 app[bot.1]:   File "/app/.heroku/python/lib/python3.11/site-packages/aiogram/bot/base.py", line 236, in request
2023-11-06T13:06:08.294794+00:00 app[bot.1]:     return await api.make_request(await self.get_session(), self.server, self.__token, method, data, files,
2023-11-06T13:06:08.294794+00:00 app[bot.1]:                  │   │                  │    │              │    │       │             │       │     └ {'photo': <InputFile 'attach://Zr7EVo7IeESjfXai5uPjYQ' with file='<_io.BufferedReader name='item_photo.jpg'>'>}
2023-11-06T13:06:08.294795+00:00 app[bot.1]:                  │   │                  │    │              │    │       │             │       └ {'chat_id': , 'caption': 'Текстові картинки з символів, які також називають ASCII арт це одне з мистецтв доступних к...
2023-11-06T13:06:08.294796+00:00 app[bot.1]:                  │   │                  │    │              │    │       │             └ 'sendPhoto'
2023-11-06T13:06:08.294796+00:00 app[bot.1]:                  │   │                  │    │              │    │       └ <aiogram.bot.bot.Bot object at 0x7fab07b39910>
2023-11-06T13:06:08.294796+00:00 app[bot.1]:                  │   │                  │    │              │    └ TelegramAPIServer(base='https://api.telegram.org/bot{token}/{method}', file='https://api.telegram.org/file/bot{token}/{path}')
2023-11-06T13:06:08.294796+00:00 app[bot.1]:                  │   │                  │    │              └ <aiogram.bot.bot.Bot object at 0x7fab07b39910>
2023-11-06T13:06:08.294796+00:00 app[bot.1]:                  │   │                  │    └ <function BaseBot.get_session at 0x7fab07f20360>
2023-11-06T13:06:08.294796+00:00 app[bot.1]:                  │   │                  └ <aiogram.bot.bot.Bot object at 0x7fab07b39910>
2023-11-06T13:06:08.294797+00:00 app[bot.1]:                  │   └ <function make_request at 0x7fab07ea3c40>
2023-11-06T13:06:08.294797+00:00 app[bot.1]:                  └ <module 'aiogram.bot.api' from '/app/.heroku/python/lib/python3.11/site-packages/aiogram/bot/api.py'>
2023-11-06T13:06:08.294797+00:00 app[bot.1]:   File "/app/.heroku/python/lib/python3.11/site-packages/aiogram/bot/api.py", line 140, in make_request
2023-11-06T13:06:08.294797+00:00 app[bot.1]:     return check_result(method, response.content_type, response.status, await response.text())
2023-11-06T13:06:08.294797+00:00 app[bot.1]:            │            │       │        │             │        │             │        └ <function ClientResponse.text at 0x7fab08381620>
2023-11-06T13:06:08.294800+00:00 app[bot.1]:            │            │       │        │             │        │             └ <ClientResponse(https://api.telegram.org/bot6738102641:AAG9NTvl5IFG1qTBDmBe7vlAHteaUFhc-zA/sendPhoto) [400 Bad Request]>
2023-11-06T13:06:08.294800+00:00 app[bot.1]:            │            │       │        │             │        │               <CIM...
2023-11-06T13:06:08.294800+00:00 app[bot.1]:            │            │       │        │             │        └ 400
2023-11-06T13:06:08.294800+00:00 app[bot.1]:            │            │       │        │             └ <ClientResponse(https://api.telegram.org/bot6738102641:AAG9NTvl5IFG1qTBDmBe7vlAHteaUFhc-zA/sendPhoto) [400 Bad Request]>
2023-11-06T13:06:08.294800+00:00 app[bot.1]:            │            │       │        │               <CIM...
2023-11-06T13:06:08.294801+00:00 app[bot.1]:            │            │       │        └ <property object at 0x7fab0854d850>
2023-11-06T13:06:08.294802+00:00 app[bot.1]:            │            │       └ <ClientResponse(https://api.telegram.org/bot6738102641:AAG9NTvl5IFG1qTBDmBe7vlAHteaUFhc-zA/sendPhoto) [400 Bad Request]>
2023-11-06T13:06:08.294802+00:00 app[bot.1]:            │            │         <CIM...
2023-11-06T13:06:08.294802+00:00 app[bot.1]:            │            └ 'sendPhoto'
2023-11-06T13:06:08.294802+00:00 app[bot.1]:            └ <function check_result at 0x7fab07ea3d80>
2023-11-06T13:06:08.294802+00:00 app[bot.1]:   File "/app/.heroku/python/lib/python3.11/site-packages/aiogram/bot/api.py", line 115, in check_result
2023-11-06T13:06:08.294803+00:00 app[bot.1]:     exceptions.BadRequest.detect(description)
2023-11-06T13:06:08.294803+00:00 app[bot.1]:     │          │          │      └ 'Bad Request: message caption is too long'
2023-11-06T13:06:08.294803+00:00 app[bot.1]:     │          │          └ <classmethod(<function _MatchErrorMixin.detect at 0x7fab080c2de0>)>
2023-11-06T13:06:08.294803+00:00 app[bot.1]:     │          └ <class 'aiogram.utils.exceptions.BadRequest'>
2023-11-06T13:06:08.294803+00:00 app[bot.1]:     └ <module 'aiogram.utils.exceptions' from '/app/.heroku/python/lib/python3.11/site-packages/aiogram/utils/exceptions.py'>
2023-11-06T13:06:08.294804+00:00 app[bot.1]:   File "/app/.heroku/python/lib/python3.11/site-packages/aiogram/utils/exceptions.py", line 141, in detect
2023-11-06T13:06:08.294804+00:00 app[bot.1]:     raise cls(description)
2023-11-06T13:06:08.294804+00:00 app[bot.1]:           │   └ 'bad request: message caption is too long'
2023-11-06T13:06:08.294804+00:00 app[bot.1]:           └ <class 'aiogram.utils.exceptions.BadRequest'>
@Salz0 Salz0 added bug Something isn't working good first issue Good for newcomers hacktoberfest labels Nov 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers hacktoberfest
Projects
None yet
Development

No branches or pull requests

1 participant