Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Make a custom exception

i have a bot and sometimes i get this error:

raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='127.0.0.1', port=23264): Max retries exceeded with url: /lol-summoner/v1/current-summoner (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x00000170037E5B10>: Failed to establish a new connection: [WinError 10061] Aucune connexion n’a pu être établie car l’ordinateur cible l’a expressément refusée'))

This happens but i don’t care, i just want my function to continue. I thought first that ConnectionError would the exception but she don’t work. What i need to do here to make a custom exception that work ? This seems really hard in that case, I’m still learning about requests and i never face this case.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Just import the error:

from requests.exceptions import ConnectionError

try:
    pass # your code here
except ConnectionError:
    pass # your error handler
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading