eternnoir / pyTelegramBotAPI

Python Telegram bot api.
GNU General Public License v2.0
8.11k stars 2.03k forks source link

What should I do to make the telebot stop handling errors? #2161

Closed Zapzatron closed 9 months ago

Zapzatron commented 9 months ago
  1. What version of pyTelegramBotAPI are you using? 4.15.3
  2. What OS are you using? Windows
  3. What version of python are you using? 3.10.9

What should I do to make the telebot stop handling errors? Because the telebot gives little information about the error. I need to be able to handle the error myself. I have class ExceptionHandler(telebot.async_telebot.ExceptionHandler):, but it doesn't always receive the error.

Example of small error information from telebot: 2024-02-08 17:17:14,295 (asyncio_helper.py:101 MainThread) ERROR - TeleBot: "Aiohttp ClientError: ClientConnectorError"

Zapzatron commented 9 months ago

Tried telebot.logger.setLevel(logging.CRITICAL + 1), but it just stopped doing logging, but it won't let me handle the error myself.

coder2020official commented 9 months ago

Set to debug to get full information.

Zapzatron commented 9 months ago

I have my own exception handler and I catch and handle errors in it. telebot.async_telebot.ExceptionHandler is sometimes called and sometimes not.

coder2020official commented 9 months ago

you can't handle connection errors with exception handler afaik

Badiboy commented 9 months ago

2024-02-08 17:17:14,295 (asyncio_helper.py:101 MainThread) ERROR - TeleBot: "Aiohttp ClientError: ClientConnectorError"

This error is raised when doing requests to Telegram. In two cases:

  1. When you make a request (like send_message). In this case you can handle it yourself when calling the function
  2. When update_requests are called. Here you can use ExceptionHandler to handle the errir.

Note, that it is re-raised as asyncio_helper.RequestTimeout exception, not Aiohttp ClientError. And the error logging will be done anyway.