1

I have the current code below:

try:
    client.run(token)
except:
    print("Connection error!")

There is one issue with this, a bare 'Except' is not a good idea. How do I type something like "Except ClientConnectorError:"?

Specific raise:

aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host discordapp.com:443 ssl:default [nodename nor servname provided, or not known]
Macintosh Fan
  • 355
  • 1
  • 4
  • 18

1 Answers1

1

I learned that you need to import the aiohttp module and use the class from there:

from aiohttp import connector

try:
    client.run(token)
except connector.ClientConnectorError:
    pass

You can of course do other actions instead of pass.

Macintosh Fan
  • 355
  • 1
  • 4
  • 18