Skip to content

Remove SolidityError in favor of ContractLogicError #2697

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

Merged
merged 2 commits into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions newsfragments/2697.breaking.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove ``SolidityError`` in favor of ``ContractLogicError``
6 changes: 3 additions & 3 deletions tests/core/utilities/test_method_formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from web3._utils.method_formatters import (
get_error_formatters,
raise_solidity_error_on_revert,
raise_contract_logic_error_on_revert,
)
from web3._utils.rpc_abi import (
RPC,
Expand Down Expand Up @@ -109,11 +109,11 @@
)
def test_get_revert_reason(response, expected) -> None:
with pytest.raises(ContractLogicError, match=expected):
raise_solidity_error_on_revert(response)
raise_contract_logic_error_on_revert(response)


def test_get_revert_reason_other_error() -> None:
assert raise_solidity_error_on_revert(OTHER_ERROR) is OTHER_ERROR
assert raise_contract_logic_error_on_revert(OTHER_ERROR) is OTHER_ERROR


def test_get_error_formatters() -> None:
Expand Down
6 changes: 3 additions & 3 deletions web3/_utils/method_formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ def apply_list_to_array_formatter(formatter: Any) -> Callable[..., Any]:
}


def raise_solidity_error_on_revert(response: RPCResponse) -> RPCResponse:
def raise_contract_logic_error_on_revert(response: RPCResponse) -> RPCResponse:
"""
Reverts contain a `data` attribute with the following layout:
"Reverted "
Expand Down Expand Up @@ -649,8 +649,8 @@ def raise_invalid_parity_mode(response: RPCResponse) -> NoReturn:


ERROR_FORMATTERS: Dict[RPCEndpoint, Callable[..., Any]] = {
RPC.eth_estimateGas: raise_solidity_error_on_revert,
RPC.eth_call: raise_solidity_error_on_revert,
RPC.eth_estimateGas: raise_contract_logic_error_on_revert,
RPC.eth_call: raise_contract_logic_error_on_revert,
RPC.parity_setMode: raise_invalid_parity_mode,
}

Expand Down
11 changes: 1 addition & 10 deletions web3/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,20 +242,11 @@ class InvalidEventABI(ValueError):
pass


class SolidityError(ValueError):
class ContractLogicError(ValueError):
# Inherits from ValueError for backwards compatibility
"""
Raised on a contract revert error
"""
pass


class ContractLogicError(SolidityError, ValueError):
# Inherits from ValueError for backwards compatibility
# TODO: Remove SolidityError inheritance in v6
"""
Raised on a contract revert error
"""


class OffchainLookup(ContractLogicError):
Expand Down