Skip to content

Commit

Permalink
fix: bttr err handling
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Sep 1, 2023
1 parent d528691 commit 87e76d1
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions ape_foundry/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -798,21 +798,33 @@ def _eth_call(self, arguments: List) -> bytes:

txn_dict.pop("chainId", None)
arguments[0] = txn_dict
trace = None

try:
result = self._make_request("eth_call", arguments)
except Exception as err:
trace, trace2 = tee(self._create_trace_frame(x) for x in self._trace_call(arguments)[1])
contract_address = arguments[0]["to"]
contract_type = self.chain_manager.contracts.get(contract_address)
method_id = arguments[0].get("data", "")[:10] or None
tb = (
SourceTraceback.create(contract_type, trace, method_id)
if method_id and contract_type
else None
)
contract_address = arguments[0].get("to") if len(arguments) > 0 else None
tb = None
if contract_address:
try:
trace, trace2 = tee(
self._create_trace_frame(x) for x in self._trace_call(arguments)[1]
)
contract_type = self.chain_manager.contracts.get(contract_address)
method_id = arguments[0].get("data", "")[:10] or None
tb = (
SourceTraceback.create(contract_type, trace2, method_id)
if method_id and contract_type
else None
)
except Exception as sub_err:
logger.error(f"Error getting source traceback: {sub_err}")

if trace is None:
trace = (self._create_trace_frame(x) for x in self._trace_call(arguments)[1])

raise self.get_virtual_machine_error(
err, trace=trace2, contract_address=contract_address, source_traceback=tb
err, trace=trace, contract_address=contract_address, source_traceback=tb
) from err

return HexBytes(result)
Expand Down

0 comments on commit 87e76d1

Please sign in to comment.