-1

I'm running Python Selenium Script, and sometimes, when the internet connexion is not working i got 2 types of errors :

timeout: Timed out receiving message from renderer: 300.000

unknown error: net::ERR_PROXY_CONNECTION_FAILED

So i want to make this; each time one of those 2 errors appears, run another script i have on my laptop

Here is the concerned part of my code:

        except Exception as e:
            print(e)
            line_count += 1
            if "Timed out" in e:
                os.system(r"C:\Users\SAMSUNG\script.py")
                print("Done")
                pass
            else:
                print("Not Concerned Error")
                pass

            if "ERR_PROXY" in e:
                os.system(r"C:\Users\SAMSUNG\script.py")
                print("Done")
                pass
            else:
                print("Not Concerned Error")
                pass

But it doesn't work! Here is my error:

if "Timed out" in e:
TypeError: argument of type 'TimeoutException' is not iterable
Sarah Guegan
  • 23
  • 1
  • 6
  • I think you're going to find your answer [here](https://stackoverflow.com/questions/51955896/how-to-catch-network-failures-while-invoking-get-method-through-selenium-and-p) – ville3 Nov 15 '20 at 11:41

1 Answers1

2

You need to convert the Exception instance to a string first:

if "Timed out" in str(e): 

If you are going to be doing multiple checks, then do the conversion once:

str_e = str(e)
...
if "Timed out" in str_e:
...
if "ERR_PROXY" in str_e:
Booboo
  • 38,656
  • 3
  • 37
  • 60