Skip to content

Commit

Permalink
Better wording for function and event identifier exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
reedsa committed Oct 17, 2024
1 parent e3e0693 commit 32c0e16
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions web3/contract/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,10 +366,13 @@ def get_function_by_identifier(
"""
if len(fns) > 1:
raise Web3ValueError(
f"Found multiple functions with matching {identifier}. " f"Found: {fns!r}"
f"Found multiple functions with matching identifier `{identifier}`. "
f"Found: {fns!r}"
)
elif len(fns) == 0:
raise Web3ValueError(f"Could not find any function with matching {identifier}")
raise Web3ValueError(
f"Could not find any function with matching identifier `{identifier}`"
)
return fns[0]


Expand Down Expand Up @@ -406,10 +409,13 @@ def get_event_by_identifier(
"""
if len(events) > 1:
raise Web3ValueError(
f"Found multiple events with matching {identifier}. " f"Found: {events!r}"
f"Found multiple events with matching identifier `{identifier}`. "
f"Found: {events!r}"
)
elif len(events) == 0:
raise Web3ValueError(f"Could not find any event with matching {identifier}")
raise Web3ValueError(
f"Could not find any event with matching identifier `{identifier}`"
)
return events[0]


Expand Down

0 comments on commit 32c0e16

Please sign in to comment.