Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle more exceptions in web3 #116

Merged
merged 2 commits into from
Aug 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/apis/web3api.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ def get_current_block_number(self) -> Optional[int]:
except ValueError as err:
self.logger.warning(f"Error while fetching block number: {err}")
return None
except Exception as err: # pylint: disable=W0718
self.logger.warning(f"Exception of type {type(err)} not handled: {err}")
return None

def get_filtered_receipts(
self, start_block: int, end_block: int, target: str, topics: list[Any]
Expand All @@ -65,6 +68,9 @@ def get_filtered_receipts(
except ValueError as err:
self.logger.warning(f"ValueError while fetching hashes: {err}")
return None
except Exception as err: # pylint: disable=W0718
self.logger.warning(f"Exception of type {type(err)} not handled: {err}")
return None
return log_receipts

def get_tx_hashes_by_block(self, start_block: int, end_block: int) -> list[str]:
Expand Down Expand Up @@ -111,7 +117,9 @@ def get_transaction(self, tx_hash: str) -> Optional[TxData]:
try:
transaction = self.web_3.eth.get_transaction(HexStr(tx_hash))
except Exception as err: # pylint: disable=W0718
self.logger.warning(f"Error while fetching transaction: {err}")
self.logger.warning(
f"Error of type {type(err)} while fetching transaction: {err}"
)
transaction = None
return transaction

Expand Down
Loading