Skip to content

Commit

Permalink
Actually catch 404 from server. This is why we listen to Codecov
Browse files Browse the repository at this point in the history
  • Loading branch information
teutoburg committed Jun 21, 2023
1 parent 722ac22 commit 44759cf
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions scopesim/server/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,20 @@ def get_server_folder_contents(dir_name: str,
unique_str: str = ".zip$") -> Iterator[str]:
url = rc.__config__["!SIM.file.server_base_url"] + dir_name

retry_strategy = Retry(total=2,
status_forcelist=[404, 429, 500, 501, 502, 503],
allowed_methods=["GET"])
adapter = HTTPAdapter(max_retries=retry_strategy)

try:
result = requests.get(url).content
except requests.exceptions.ConnectionError as error:
with requests.Session() as session:
session.mount("https://", adapter)
result = session.get(url).content
except (requests.exceptions.ConnectionError,
requests.exceptions.RetryError) as error:
logging.error(error)
raise ServerError("Cannot connect to server.") from error
raise ServerError("Cannot connect to server. "
f"Attempted URL was: {url}.") from error
except Exception as error:
logging.error(("Unhandled exception occured while accessing server."

Check warning on line 96 in scopesim/server/database.py

View check run for this annotation

Codecov / codecov/patch

scopesim/server/database.py#L96

Added line #L96 was not covered by tests
"Attempted URL was: %s."), url)
Expand Down

0 comments on commit 44759cf

Please sign in to comment.