Raise BrokenPreconditionError on invalid inputs#4957
Conversation
60f7c26 to
eba97be
Compare
karlb
left a comment
There was a problem hiding this comment.
@rakanalh In #4936 (comment) you said that these should not be BrokenPreconditionErrors. Have you been convinced? It looks sensible to me.
| """ Raised if the token does not follow the ERC20 standard """ | ||
|
|
||
|
|
||
| class InvalidTokenAddress(RaidenError): |
There was a problem hiding this comment.
Instead of removing these, you could make InvalidTokenAddress a subclass of BrokenPreconditionError. Fine grained exceptions are usually a nice thing, e.g. you could mark wrong input fields in the UI or add error codes to exceptions and pass them to API users.
There was a problem hiding this comment.
No, I'm not sure. When the API raises these exceptions, that should not crash the node.
Also I've seen that the proxy should not raise specific errors #4878 (comment). I'm seeing another contradiction here.
There was a problem hiding this comment.
@rakanalh, in the end, are proxies allowed to raise specific errors? If yes, in which circumstances? I'll document and follow what you say.
|
@rakanalh said these should not be BrokenPreconditionError. When I read the docstring of BrokenPreconditionError, it says something like |
because the caller of the proxy should have checked these inputs.
The documentation for BrokenPreconditionError clearly says
```
class BrokenPreconditionError(RaidenError):
""" Raised while checking transaction preconditions
which should be satisfied before sending the transaction.
This exception when:
1. An assert or a revert in the smart contract would be hit for
triggering block.
2. If provided values are invalid (i.e ValueError)
"""
```
So, when the provided values are invalid, BrokenPreconditionError
should be raised.
eba97be to
efcbb7a
Compare
|
On the second point, we agreed that the BrokenPreconditionError is for blockchain checks. |
because the caller of the proxy should have checked these inputs.
The documentation for BrokenPreconditionError clearly says
So, when the provided values are invalid, BrokenPreconditionError
should be raised.
This PR comes from a discussion in #4936 (review)
Description
Please, describe what this PR does in detail:
This is a bug fix. Before this PR, the proxy raised a recoverable error even when invalid values are passed.
PR review check list
Quality check list that cannot be automatically verified.