ethers.js: Web3Provider Error not parsed correctly

When a transaction submitted through the Web3Provider reverts, ethers will sometimes parse it as a “gas too low” error even though there is another cause.

See the screenshot attached. The top error (which I’m not able to catch) clearly shows the message is “commitment too new”, while ethers thinks it’s something else.

It would be good to also be able to access the original error object. At the moment it looks like I can only access the string, which I log below the original message.

image

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 16 (7 by maintainers)

Most upvoted comments

Oh! One more thought. This is prolly a lot more work, and may require paid tiers to INFURA and Alchemy (or running your own Geth with tracing enabled), but if a transaction fails, there are trace_ and debug_ APIs available that can recover what went wrong.

But a tracing node is substantially more expensive to run.

Are you using MetaMask? That result seems very bizarre, since it includes a status but the blockNumber and blockHash are null.

It’s only able to display the succinct message if the backend sends it in a machine readable format. But that is only possible in a call, the Ethereum JSON-RPC gobbles it up in its return value.

We are having a couple meetings per month though to get the JSON-RPC API cleaned up a bit though. This sort of thing is exactly what we’ve spent the last few months discussing. 😃

But it likely won’t be resolved any time soon… 😒