Skip to content
Snippets Groups Projects
Commit 18912166 authored by Carsten Hinz's avatar Carsten Hinz
Browse files

unified output for HTTP exceptions

parent 4fcf7b20
Branches
Tags
1 merge request!11Creation of first beta release version
......@@ -193,6 +193,7 @@ class Connection:
response.raise_for_status()
except requests.exceptions.HTTPError as e:
print(f"\tconnection error ({e.response.status_code}: {e.response.reason}). Trying again later")
self.printExecption(e)
continue
#are our results ready to obtain?
if response.headers["Content-Type"] == "application/zip":
......@@ -228,9 +229,7 @@ class Connection:
except requests.exceptions.HTTPError as e:
#TODO add detailed processing: What was the reason for the error? Do we really need to create a new request or is there another problem, that might resolve by simply waiting
print(f"A connection error occurred:")
print(f"Status Code: {e.response.status_code}")
print(f"Reason: {e.response.reason}")
print(f"Text: {e.response.text}")
self.printExecption(e)
print(f"Status Endpoint: {status_endpoint}")
#use inverse order for saving. the status endpoint should be more unique
self.cache_backup.put(status_endpoint, query_options.cache_key)
......@@ -263,9 +262,8 @@ class Connection:
response = self.wait_and_get(self.endpoint, asdict(query_options, dict_factory=quarryToDict))
except requests.exceptions.HTTPError as e:
print(f"A connection error occurred:")
print(f"Status Code: {e.response.status_code}")
print(f"Reason: {e.response.reason}")
print(f"Text: {e.response.text}")
self.printExecption(e)
print(f"{response=}")
raise e
except requests.exceptions.ReadTimeout as e:
print("Caught read timeout.")
......@@ -301,6 +299,12 @@ class Connection:
time.sleep(wait_secs)
return requests.get(endpoint, params=query_options, timeout=timeout)
def printExecption(self, e : requests.exceptions.HTTPError):
print(f"Status Code: {e.response.status_code}")
print(f"Reason: {e.response.reason}")
print(f"Text: {e.response.text}")
print(f"{e.response.raw=}")
print(f"{e.response=}")
class AnalysisService:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment