Skip to content

Commit

Permalink
add try catch for exception
Browse files Browse the repository at this point in the history
  • Loading branch information
claravox committed Sep 9, 2024
1 parent a082ea8 commit 7f09407
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions troubleshoot_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,11 @@ def compare_local_remote_files(ctx, file_path, url):
# We are comparing small files so it should be ok to get the whole file
local_data = data_object.read(ctx, file_path)

response = requests.get(url, verify=False)
try:
response = requests.get(url, verify=False)
except requests.exceptions.ConnectionError:
return False

if response.status_code != 200:
log.write_stdout(ctx, "Error {} when connecting to <{}>.".format(response.status_code, url))
return False
Expand Down Expand Up @@ -262,7 +266,11 @@ def check_combi_json(ctx, data_package, publication_config):
# TODO check if this fails
version_doi = avu.get_val_of_coll(ctx, data_package, attr)
url = "https://{}/oai/oai?verb=GetRecord&metadataPrefix=oai_datacite&identifier=oai:{}".format(publication_config[remote_hostname], version_doi)
response = requests.get(url, verify=False)
try:
response = requests.get(url, verify=False)
except requests.exceptions.ConnectionError:
return False

if response.status_code != 200:
log.write_stdout(ctx, "Error {} when connecting to <{}>.".format(response.status_code, url))
return False
Expand Down

0 comments on commit 7f09407

Please sign in to comment.