Skip to content
This repository was archived by the owner on Oct 12, 2023. It is now read-only.

Commit 0823da1

Browse files
committed
Merge pull request #179 from nrejack/develop
Adding exception handling for NewConnectionError in redi/utils/redc…
2 parents 0dfb703 + 2f8d13b commit 0823da1

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

redi/utils/redcapClient.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from redcap import Project, RedcapError
2121
from requests import RequestException
2222
from requests.packages.urllib3.exceptions import MaxRetryError
23+
from requests.packages.urllib3.exceptions import NewConnectionError
2324

2425
# Configure module's logger
2526
logger = logging.getLogger(__name__)
@@ -110,10 +111,13 @@ def send_data_to_redcap(self, data, max_retry_count, overwrite=False,
110111
try:
111112
# The following line simulates github issue #108:
112113
# raise MaxRetryError('', 'localhost:8998', None)
114+
# The following line simulates
115+
#raise NewConnectionError('localhost:8998', 443)
113116
response = self.project.import_records(data,
114117
overwrite=overwrite_value)
115118
return response
116-
except MaxRetryError as e:
119+
except (MaxRetryError, NewConnectionError) as e:
120+
logger.error("Exception encountered: ", exc_info = True)
117121
logger.debug(e.message + ", Attempt no.: " + str(retry_count))
118122
if (retry_count == max_retry_count):
119123
message = "Exiting since network connection timed out after"\

0 commit comments

Comments
 (0)