Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
reedsa committed Sep 6, 2023
1 parent 94e7332 commit be6672a
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions web3/_utils/contract_error_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,20 +134,22 @@ def raise_contract_logic_error_on_revert(response: RPCResponse) -> RPCResponse:
message_present = message is not None and message != ""
data = error.get("data", MISSING_DATA)

if data is None:
if message_present:
raise ContractLogicError(message, data=data)
elif not message_present:
raise ContractLogicError("execution reverted", data=data)
elif isinstance(data, dict) and message_present:
raise ContractLogicError(f"execution reverted: {message}", data=data)

_raise_error_from_decoded_revert_data(data)

if message_present:
if data is None:
raise ContractLogicError(message, data=data)
elif isinstance(data, dict):
raise ContractLogicError(f"execution reverted: {message}", data=data)
elif code == 3:
# Geth Revert with error message and code 3 case:
# Geth Revert with error message and code 3 case:
if code == 3:
raise ContractLogicError(message, data=data)
# Geth Revert without error message case:
elif "execution reverted" in message:
raise ContractLogicError("execution reverted", data=data)

if data is None and not message_present:
raise ContractLogicError("execution reverted", data=data)

return response

0 comments on commit be6672a

Please sign in to comment.