-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Formatting revert error objects #871
Comments
That part should not change. The revert reason at some point may be also available in the main error, but this requires a bit more effort, since it isn’t being fed back in a nice machine readable way and each backend seems to choose their own format. :( |
I think it's fine if it did change during the beta/prerelease version. But that's great if the API doesn't change.
Did you mean extracting
This can also be a call for standardizing the format across clients by proposing a simple addition in the ETH specification through which clients would stay consistent. It would make libraries to throw pretty errors and better errors in the UI too. |
I agree, it'd be nice if there was a standard. Many parts of ethers tries to coalesce these errors already. For example, the various ways a node indicates "already seen" is captured and converted to a NONCE_EXPIRED error. The message from the server is still available, but many apps don'w need to worry about that. It is harder with app-generated errors. I'm going to look at this right now. I might make the above throw a CALL_EXCEPTION error, instead of a SERVER_ERROR. Let me look into this for a day or two. :) |
(once v5 is out of beta though, these things should almost certainly not change though; any change would have to wait until v6) |
Actually, I tried this and got the CALL_EXCEPTION error, I'd expect. What backend are you using that returned a SERVER_ERROR instead? |
Sorry for the spam. Looks like you are using Ganache. If you use a normal backend, like Geth, you will probably get the correct error in response. I think there is a way to turn Ganache into "standards-compliant" mode... It would be nice if ethers could unpack this though and expose the error, but I don't know how feasible that is, since Ganache seems to change their output from time-to-time... |
If it's giving a proper error on a standard client, that's really awesome! (I've not yet tried this with v5, will try later when deploying contracts on a test network).
I tried to look into docs (README) and issues of
If it's a trouble with Ganache, I don't think super important to also cover Ganache. As long as main clients like Geth and Parity/OpenEthereum are already covered, users would see a nice error in the UI. For the ganache part, developers can parse the error message if they need by themselves in their testcases depending on the test EVM or version they are using.
For now, I think ganache just giving an output like what current v4 is giving is enough instead of a processing response error, it would be nice for any smart contract developer upgrading to v5. Because currently, if a method throws in a mocha test, it shows 5-6 full lines of stuff in red. It can be replaced with just one red line: |
I think this issue may be stale, so I'm closing it. If not, please feel free to re-open or start a new issue/discussion. Thanks! :) |
When a contract method reverts, it throws an error: "processing response error".
In the v5, the
error.message
contains lot of stuff including the actual rpc response from the node. While in v4,error.message
contained only the error message string from the JSON RPC error.ethers v5 revert error object:
ethers v4 revert error object (from a different project) looks like:
Though I can access the revert message from
err.error.message
for now, I wanna confirm if reverts will be formatted in future, it might cause tests I'm writing to break.The text was updated successfully, but these errors were encountered: