Skip to content

Commit

Permalink
added try except for some API calls
Browse files Browse the repository at this point in the history
catches requests.exceptions.ConnectionError now
  • Loading branch information
fhenneke committed May 25, 2023
1 parent 685e2b3 commit b5827c2
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/monitoring_tests/template_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,14 @@ def get_tx_hashes_by_block(cls, start_block: int, end_block: int) -> List[str]:
# therefore, check if hash has already been added to the list

# only successful transactions are filtered
transactions = cls.web_3.eth.filter(filter_criteria).get_all_entries() # type: ignore
try:
transactions = cls.web_3.eth.filter(filter_criteria).get_all_entries() # type: ignore
except requests.exceptions.ConnectionError as except_err:
cls.logger.error(
"Connection error while fetching hashes: %s.",
str(except_err),
)
transactions = []
settlement_hashes_list = []
for transaction in transactions:
tx_hash = (transaction["transactionHash"]).hex()
Expand Down Expand Up @@ -114,8 +121,11 @@ def get_solver_competition_data(
solver_competition_data.append(
json.loads(barn_competition_data.text)
)
except ValueError as except_err:
cls.logger.error("Unhandled exception: %s.", str(except_err))
except requests.exceptions.ConnectionError as except_err:
cls.logger.error(
"Connection error while fetching competition data: %s.",
str(except_err),
)

return solver_competition_data

Expand Down

0 comments on commit b5827c2

Please sign in to comment.