-
I've toyed around a bit with the error handler example code errorhandlerbot.py, for Application.builder based PTB applications. The code comments seem to indicate that the handler is only called on errors that happen during the registered message handler callback functions, and the Exception Handling Docu indicates this as well. On the Handling Network Errors Page, there is some hinting towards catching exceptions, but no specific suggestion how to catch exceptions raised by httpx. With the raw bot, this was easy: a try-catch-block around Background: aim is to detect network outage errors asap (i.e. I don't want to tweak connection timeout settings to cover things up), log a brief warning message, recover automatically (PTB already does this)... Is there already example code for catching httpx exceptions in Application.builder based applications that I missed? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Solved itself!
This will pass network errors from httpx into the error_handler() function, there they can be detected using |
Beta Was this translation helpful? Give feedback.
-
btw... suggest to add this info to the Networking Error page... |
Beta Was this translation helpful? Give feedback.
Solved itself!
I found this posting 3430 by Bibo-Joshi.
This is the working code snippet, for reference: