Skip to content

Commit

Permalink
Improve error handling, remove separate handler for KeyboardInterrupt
Browse files Browse the repository at this point in the history
  • Loading branch information
teutoburg committed Jun 23, 2023
1 parent a05bc44 commit faa9967
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions scopesim/server/github_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ def download_github_folder(repo_url: str,
api_url, download_dirs = create_github_url(repo_url)

# get the contents of the github folder
user_interrupt_text = "GitHub download interrupted by User"
try:
retry_strategy = Retry(total=3, backoff_factor=2,
status_forcelist=HTTP_RETRY_CODES,
Expand All @@ -82,9 +81,6 @@ def download_github_folder(repo_url: str,
logging.error(error)
raise ServerError("Cannot connect to server. "
f"Attempted URL was: {api_url}.") from error
except KeyboardInterrupt as error:
logging.error(user_interrupt_text)
raise error
except Exception as error:
logging.error(("Unhandled exception occured while accessing server."
"Attempted URL was: %s."), api_url)
Expand All @@ -110,6 +106,13 @@ def download_github_folder(repo_url: str,
padlen=0, disable_bar=True)
logging.info("Downloaded: %s", entry["path"])

except KeyboardInterrupt as error:
logging.error(user_interrupt_text)
except (requests.exceptions.ConnectionError,
requests.exceptions.RetryError) as error:
logging.error(error)
raise ServerError("Cannot connect to server. "
f"Attempted URL was: {api_url}.") from error
except Exception as error:
logging.error(("Unhandled exception occured while accessing "
"server. Attempted URL was: %s."), api_url)
logging.error(error)
raise error

0 comments on commit faa9967

Please sign in to comment.