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
No related branches found
No related tags found
1 merge request!11Creation of first beta release version
...@@ -193,6 +193,7 @@ class Connection: ...@@ -193,6 +193,7 @@ class Connection:
response.raise_for_status() response.raise_for_status()
except requests.exceptions.HTTPError as e: except requests.exceptions.HTTPError as e:
print(f"\tconnection error ({e.response.status_code}: {e.response.reason}). Trying again later") print(f"\tconnection error ({e.response.status_code}: {e.response.reason}). Trying again later")
self.printExecption(e)
continue continue
#are our results ready to obtain? #are our results ready to obtain?
if response.headers["Content-Type"] == "application/zip": if response.headers["Content-Type"] == "application/zip":
...@@ -228,9 +229,7 @@ class Connection: ...@@ -228,9 +229,7 @@ class Connection:
except requests.exceptions.HTTPError as e: 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 #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"A connection error occurred:")
print(f"Status Code: {e.response.status_code}") self.printExecption(e)
print(f"Reason: {e.response.reason}")
print(f"Text: {e.response.text}")
print(f"Status Endpoint: {status_endpoint}") print(f"Status Endpoint: {status_endpoint}")
#use inverse order for saving. the status endpoint should be more unique #use inverse order for saving. the status endpoint should be more unique
self.cache_backup.put(status_endpoint, query_options.cache_key) self.cache_backup.put(status_endpoint, query_options.cache_key)
...@@ -263,9 +262,8 @@ class Connection: ...@@ -263,9 +262,8 @@ class Connection:
response = self.wait_and_get(self.endpoint, asdict(query_options, dict_factory=quarryToDict)) response = self.wait_and_get(self.endpoint, asdict(query_options, dict_factory=quarryToDict))
except requests.exceptions.HTTPError as e: except requests.exceptions.HTTPError as e:
print(f"A connection error occurred:") print(f"A connection error occurred:")
print(f"Status Code: {e.response.status_code}") self.printExecption(e)
print(f"Reason: {e.response.reason}") print(f"{response=}")
print(f"Text: {e.response.text}")
raise e raise e
except requests.exceptions.ReadTimeout as e: except requests.exceptions.ReadTimeout as e:
print("Caught read timeout.") print("Caught read timeout.")
...@@ -301,6 +299,12 @@ class Connection: ...@@ -301,6 +299,12 @@ class Connection:
time.sleep(wait_secs) time.sleep(wait_secs)
return requests.get(endpoint, params=query_options, timeout=timeout) 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: class AnalysisService:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment