Skip to content

Commit ebfbfb2

Browse files
committed
added posibility to handle exception on RequestTimeout
1 parent 0f52ca6 commit ebfbfb2

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

‎telebot/async_telebot.py‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,8 +415,16 @@ async def _process_polling(self, non_stop: bool=False, interval: int=0, timeout:
415415
except asyncio.CancelledError:
416416
return
417417
except asyncio_helper.RequestTimeout as e:
418-
logger.error(str(e))
419-
if non_stop:
418+
handled = False
419+
if self.exception_handler:
420+
self.exception_handler.handle(e)
421+
handled = True
422+
423+
if not handled:
424+
logger.error('Unhandled exception (full traceback for debug level): %s', str(e))
425+
logger.debug(traceback.format_exc())
426+
427+
if non_stop or handled:
420428
await asyncio.sleep(2)
421429
continue
422430
else:

0 commit comments

Comments
 (0)