Skip to content

Commit b5827c2

Browse files
committed
added try except for some API calls
catches requests.exceptions.ConnectionError now
1 parent 685e2b3 commit b5827c2

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

src/monitoring_tests/template_test.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,14 @@ def get_tx_hashes_by_block(cls, start_block: int, end_block: int) -> List[str]:
6969
# therefore, check if hash has already been added to the list
7070

7171
# only successful transactions are filtered
72-
transactions = cls.web_3.eth.filter(filter_criteria).get_all_entries() # type: ignore
72+
try:
73+
transactions = cls.web_3.eth.filter(filter_criteria).get_all_entries() # type: ignore
74+
except requests.exceptions.ConnectionError as except_err:
75+
cls.logger.error(
76+
"Connection error while fetching hashes: %s.",
77+
str(except_err),
78+
)
79+
transactions = []
7380
settlement_hashes_list = []
7481
for transaction in transactions:
7582
tx_hash = (transaction["transactionHash"]).hex()
@@ -114,8 +121,11 @@ def get_solver_competition_data(
114121
solver_competition_data.append(
115122
json.loads(barn_competition_data.text)
116123
)
117-
except ValueError as except_err:
118-
cls.logger.error("Unhandled exception: %s.", str(except_err))
124+
except requests.exceptions.ConnectionError as except_err:
125+
cls.logger.error(
126+
"Connection error while fetching competition data: %s.",
127+
str(except_err),
128+
)
119129

120130
return solver_competition_data
121131

0 commit comments

Comments
 (0)