Skip to content
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

Outputs "Unexpected error" for expected errors #5186

Closed
rimrakhimov opened this issue May 8, 2024 · 0 comments
Closed

Outputs "Unexpected error" for expected errors #5186

rimrakhimov opened this issue May 8, 2024 · 0 comments
Assignees
Labels
status:ready This issue is ready to be worked on

Comments

@rimrakhimov
Copy link
Contributor

rimrakhimov commented May 8, 2024

Version of Hardhat

2.22.3

What happened?

Hardhat outputs

An unexpected error occurred during the verification process.
Please report this issue to the Hardhat team.

for ContractVerificationInvalidStatusCodeError and ContractVerificationMissingBytecodeError errors.

For example, if ContractVerificationMissingBytecodeError error has been thrown, hardhat outputs:

An unexpected error occurred during the verification process.
Please report this issue to the Hardhat team.
Error Details: Failed to send contract verification request.
Endpoint URL: https://api-hardhat.etherscan.io/api
Reason: The Etherscan API responded that the address 0x5FbDB2315678afecb367f032d93F642f64180aa3 does not have bytecode.
This can happen if the contract was recently deployed and this fact hasn't propagated to the backend yet.
Try waiting for a minute before verifying your contract. If you are invoking this from a script,
try to wait for five confirmations of your contract deployment transaction before running the verification subtask.

But I believe they are actually expected and should be caught in those lines.

Solution

That happens because those errors are inherited from classes which have setPrototypeOf methods in their constructors. E.g.,

Object.setPrototypeOf(this, NomicLabsHardhatPluginError.prototype);
. If all such assignments removed, those errors are caught successfully.

I don't know why those assignments have been added, though, and whether removing them will have no undesired effects


The same considerations apply to ContractStatusPollingInvalidStatusCodeError and ContractStatusPollingResponseNotOkError in those lines. The corresponding test case.

Minimal reproduction steps

To reproduce, for ContractVerificationMissingBytecodeError you may update the regexp in this test case (e.g., "someprefixThe Etherscan API responded that the address ..."), so you can get the actual error message hardhat returns

Search terms

No response

@kanej kanej added status:ready This issue is ready to be worked on and removed status:triaging labels May 9, 2024
@kanej kanej closed this as completed May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:ready This issue is ready to be worked on
Projects
Archived in project
Development

No branches or pull requests

4 participants