Skip to content

Commit

Permalink
irc: separate ConnectionError from OSError
Browse files Browse the repository at this point in the history
  • Loading branch information
Exirel committed Apr 8, 2023
1 parent 3a81afa commit b4e334a
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions sopel/irc/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,11 @@ async def _run_forever(self) -> None:
**connection_kwargs,
)

# SSL Error
# SSL Errors (certificate verification and generic SSL errors)
except ssl.SSLCertVerificationError as err:
LOGGER.error(
'Unable to connect due to SSL certificate verification failure: %s',
'Unable to connect due to '
'SSL certificate verification failure: %s',
err,
)
self.log_exception()
Expand All @@ -413,7 +414,7 @@ async def _run_forever(self) -> None:
self.bot.wantsrestart = False
return

# Specific connection error
# Specific connection error (invalid address and timeout)
except socket.gaierror as err:
LOGGER.error(
'Unable to connect due to invalid IRC server address: %s',
Expand All @@ -438,12 +439,18 @@ async def _run_forever(self) -> None:
self.bot.wantsrestart = False
return

# Generic connection error (OSError is used for any connection error)
# Generic connection error
except ConnectionError as err:
LOGGER.error('Unable to connect: %s', err)
self.log_exception()
# tell the bot to quit without restart
self.bot.hasquit = True
self.bot.wantsrestart = False
return

# Generic OSError (used for any unspecitic connection error)
except OSError as err:
LOGGER.error(
'Unable to connect: %s',
err,
)
LOGGER.error('Unable to connect: %s', err)
LOGGER.error(
'You should verify that "%s:%s" is the correct address '
'to connect to the IRC server.',
Expand Down

0 comments on commit b4e334a

Please sign in to comment.