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

full traceback for async_telebot #2346

Closed
wants to merge 1 commit into from
Closed

full traceback for async_telebot #2346

wants to merge 1 commit into from

Conversation

z44d
Copy link
Contributor

@z44d z44d commented Jul 13, 2024

AsyncTelebot is only showing the error message in handlers.., after using logger.exception() instead of logger.error(), it's showing full trackback totally like TeleBot.

  • Before:
2024-07-13 14:00:05,724 (async_telebot.py:564 MainThread) ERROR - TeleBot: "A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: chat not found"
  • After:
Traceback (most recent call last):
  File "/home/zaid/.local/lib/python3.12/site-packages/telebot/async_telebot.py", line 537, in _run_middlewares_and_handlers
    result = await handler['function'](message)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zaid/Desktop/a/main.py", line 10, in on_start
    return await bot.send_message(
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zaid/.local/lib/python3.12/site-packages/telebot/async_telebot.py", line 3174, in send_message
    await asyncio_helper.send_message(
  File "/home/zaid/.local/lib/python3.12/site-packages/telebot/asyncio_helper.py", line 310, in send_message
    return await _process_request(token, method_name, params=params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zaid/.local/lib/python3.12/site-packages/telebot/asyncio_helper.py", line 99, in _process_request
    raise e
  File "/home/zaid/.local/lib/python3.12/site-packages/telebot/asyncio_helper.py", line 95, in _process_request
    json_result = await _check_result(url, resp)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zaid/.local/lib/python3.12/site-packages/telebot/asyncio_helper.py", line 274, in _check_result
    raise ApiTelegramException(method_name, result, result_json)
telebot.asyncio_helper.ApiTelegramException: A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: chat not found

it's better to know in which line you made mistake.

@coder2020official
Copy link
Collaborator

It is already displayed through debug

@Badiboy
Copy link
Collaborator

Badiboy commented Jul 13, 2024

image

Use DEBUG level to get full traceback.

@Badiboy Badiboy closed this Jul 13, 2024
@z44d z44d deleted the asyncio branch July 13, 2024 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants