From 78450b9f6b18f745c0308c637e8b760ec39e0bd4 Mon Sep 17 00:00:00 2001 From: David Huss <dh@atoav.com> Date: Wed, 9 Jun 2021 12:20:25 +0200 Subject: [PATCH] Better Error handling on broken connections --- stechuhr_client/client.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/stechuhr_client/client.py b/stechuhr_client/client.py index 2e7779b..8bcd347 100644 --- a/stechuhr_client/client.py +++ b/stechuhr_client/client.py @@ -372,7 +372,13 @@ def update_id_patterns(config, logger) -> 'Config': try: r = requests.get(url, timeout=config["server"]["timeout"]) except requests.packages.urllib3.exceptions.MaxRetryError as e: - logger.error(f"Couldn't reach server at \"{url}\" (using existing patterns instead): {e}") + logger.error(f"Couldn't reach server at \"{url}\" (Timeout, using existing patterns instead): {e}") + return config + except requests.packages.urllib3.exceptions.ConnectionRefusedError as e: + logger.error(f"Couldn't reach server at \"{url}\" (Connection Refused, using existing patterns instead): {e}") + return config + except requests.packages.urllib3.exceptions.NewConnectionError as e: + logger.error(f"Couldn't reach server at \"{url}\" (NewConnectionError, using existing patterns instead): {e}") return config # If the response was ok update the pattern if it changed, else display a warning -- GitLab