Stack trace of failure to encode a tuple doesn't help locate caller #3671
-
I have a custom hardhat task which is attempting to call a contract with a write function which takes a tuple as the second parameter. It is failing with the following stack trace (after adding
As you can see, the bottom stack frame is In this case, it's not a big deal because the task only sends a single transaction, so I know that the error is almost certainly triggered by that. But if it wasn't obvious, this would be an unpleasant situation, and I'd have to resort to sprinkling a load of So I'm wondering if there's any way Hardhat could do a better job of handling the error here, e.g. by catching the exception in the caller and logging the stack trace of the caller in addition to the stack trace of the async thread. I found an explainer of node.js's event model which seemed to suggest that this might not be possible due to how node.js works; however a different Hardhat custom task in the same project was able to give a far more helpful stack trace:
Notice how here the stack trace continues beyond Thanks! (BTW the problem would have been lessened if the error message at the top of the stack trace
was less cryptic - I have submitted ethers-io/ethers.js#3772 about that.) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey @aspiers. The reason this happens in one task and not in the other is that the first one is handled by ethers. The top frames in that trace gives you a hint of what's going on: ethers captures an error and creates its own thing, which sometimes hides information that comes from Hardhat. We are aware of the issue but haven't been able to do much about it. I'm not sure if ethers v6 handles this better, hopefully it does. |
Beta Was this translation helpful? Give feedback.
Hey @aspiers. The reason this happens in one task and not in the other is that the first one is handled by ethers. The top frames in that trace gives you a hint of what's going on: ethers captures an error and creates its own thing, which sometimes hides information that comes from Hardhat.
We are aware of the issue but haven't been able to do much about it. I'm not sure if ethers v6 handles this better, hopefully it does.