AV-98-fork

A fork of https://tildegit.org/solderpunk/AV-98
Log (Feed) | Files | Refs (Tags) | README | LICENSE

commit 9d9b0440801df5447052457d62c855651bfcc2d3
parent a968fd3f92e6567cc35528fe3c55d44fd7e76d11
Author: Solderpunk <solderpunk@sdf.org>
Date:   Tue, 13 Aug 2019 19:58:05 +0300

Simplify Exception handling a bit.  Unlike in VF-1, we can't recover from network errors with redundant mirrors, so there's no need to separate network errors from other errors early on.

Diffstat:
Mav98.py | 19+++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/av98.py b/av98.py @@ -228,28 +228,23 @@ class GeminiClient(cmd.Cmd): self._debug("Response header: %s." % header) # Catch network errors which may happen on initial connection - except (socket.gaierror, ConnectionRefusedError, - ConnectionResetError, TimeoutError, socket.timeout, - ) as network_error: + except Exception as err: # Print an error message - if isinstance(network_error, socket.gaierror): + if isinstance(err, socket.gaierror): self.log["dns_failures"] += 1 print("ERROR: DNS error!") - elif isinstance(network_error, ConnectionRefusedError): + elif isinstance(err, ConnectionRefusedError): self.log["refused_connections"] += 1 print("ERROR: Connection refused!") - elif isinstance(network_error, ConnectionResetError): + elif isinstance(err, ConnectionResetError): self.log["reset_connections"] += 1 print("ERROR: Connection reset!") - elif isinstance(network_error, (TimeoutError, socket.timeout)): + elif isinstance(err, (TimeoutError, socket.timeout)): self.log["timeouts"] += 1 print("""ERROR: Connection timed out! Slow internet connection? Use 'set timeout' to be more patient.""") - return - - # Catch other errors - except Exception as err: - print("ERROR: " + str(err)) + else: + print("ERROR: " + str(err)) return # Validate header