Open NandyBa opened 4 months ago
It agree it is quite easy to miss, one of the clear indications is when the trace shows that you are calling methods on address(0)
I'm open to having improvements for this but I don't know how technically feasible this would be and what the rate of false positives would be like in a forking scenario. (cc @klkvr)
Component
Forge
Describe the feature you would like
Proposal: Enhanced Error Handling for Calls to Uninitialized Contracts
Managing multiple contracts can occasionally lead to an oversight where one contract is not initialized. This oversight typically results in a
EvmError: Revert;
error, which is often detected only at the end of the execution stack. This not only makes debugging challenging but also time-consuming.I propose to implement a mechanism that specifically catches this type of error and, in response, provides a more explicit and informative error message, such as
Error: Contract not initialized.
By doing so, we aim to alert developers to the precise nature of the issue more quickly, making it easier to identify and rectify the oversight of not initializing a contract.Additional context
Here's a revised version of your message for clarity and correctness:
Additional Context
During ETH Oxford, I encountered an issue that took me a while to resolve due to the lack of an explicit error message.
How it Occurred: The issue arises when executing
forge test
and calling a function within your contract that triggers another contract. If you specify the contract but forget to initialize it, you encounter a non-explicit error:EvmError: Revert;
.Reproducible Error:
Note: I have simplified the implementation to get a short reproductible code