-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Raise exceptions rather than return None in all jsonrpc calls #1218
Raise exceptions rather than return None in all jsonrpc calls #1218
Conversation
e94441c
to
2ac48f6
Compare
@pipermerriam What other |
80a0da7
to
0cb275b
Compare
0cb275b
to
5f3eb60
Compare
e8d6fc3
to
56bea98
Compare
@pipermerriam ping for review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me @njgheorghita!
@@ -107,6 +110,9 @@ def request_blocking(self, method, params): | |||
if "error" in response: | |||
raise ValueError(response["error"]) | |||
|
|||
if response['result'] is None: | |||
raise ValueError(f"The call to {method} did not return a value.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me.
@@ -107,6 +110,9 @@ def request_blocking(self, method, params): | |||
if "error" in response: | |||
raise ValueError(response["error"]) | |||
|
|||
if response['result'] is None: | |||
raise ValueError(f"The call to {method} did not return a value.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me.
@@ -485,8 +485,8 @@ def test_eth_getBlockByHash(self, web3, empty_block): | |||
assert block['hash'] == empty_block['hash'] | |||
|
|||
def test_eth_getBlockByHash_not_found(self, web3, empty_block): | |||
block = web3.eth.getBlock(UNKNOWN_HASH) | |||
assert block is None | |||
with pytest.raises(ValueError): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realize that I'm late to the party on this one, but I think that this should be a custom exception for each object type.
BlockNotFound
TransactionNotFound
(use this for receipt fetching too)- anything else?
What was wrong?
#722 (comment)
How was it fixed?
Raised a
ValueError
if return value fromManager._make_request()
isNone
Cute Animal Picture