Handling Custom Error
Handling Custom Error
Loading saved threads...
AAIIWITF · External communityPost link
External question — Ethereum Stack Exchange
Author: AAIIWITF
Original post: https://ethereum.stackexchange.com/questions/134462
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
Why it doesn't work when I use...
$ yarn hardhat --verison 2.10.2
await expect(fundMeConnectedContract.withdraw()
).to.be.revertedWith(
"FundMe__NotOwner"
)
but this worked
await expect(fundMeConnectedContract.withdraw()
).to.be.revertedWithCustomError(
fundMeConnectedContract,
"FundMe__NotOwner"
)
Has the hardhat custom error handling changed since May this year..??
Quote
Report
sola24 · External communityPost link
External answer — Ethereum Stack Exchange
Author: sola24
Original post: https://ethereum.stackexchange.com/a/134466
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
the former is matching against the revert message.
e.g.
.to.be.revertedWith("go away")
would work with this code
require(msg.sender == owner,"go away");
the latter is just matching against the custom error
Quote
Report
Alphard1188118 · External communityPost link
External answer — Ethereum Stack Exchange
Author: Alphard1188118
Original post: https://ethereum.stackexchange.com/a/137823
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
await expect(fundMeConnectedContract.withdraw()).to.be.revertedWithCustomError(fundMe, "FundMe__NotOwner")
Hey , buddy if you follow exactly the tutorial. try
revertedWithCustomError
and add
fundMe, "FundMe__NotOwner"
.
Line explanation :
fundMe
will be your deployed contract
FundMe__NotOwner
the custom error from
fundMe.sol
Do also check if you using single or double underscore
for
FundMe__NotOwner
in
fundMe.sol
I hope this would help if you still not found out the solution
Quote
Report
Francis G MBT · External communityPost link
External answer — Ethereum Stack Exchange
Author: Francis G MBT
Original post: https://ethereum.stackexchange.com/a/142050
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
I hope you got an Answer already, if not just try to delete the custom error passed to revertedWithCustomError and write it down yourself. I copie-pasted it and it could not recognise as defined custom-Error in the contract.
Quote
Report
Post Reply
Quoted from Forex.com.bd-Editorial External answer — Ethereum Stack Exchange Author: Francis G MBT Source score (net votes, not local likes): 0 Original post: https://ethereum.stackexchange.com/a/142050 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I hope you got an Answer already, if not just try to delete the custom error passed to revertedWithCustomError and write it down yourself. I copie-pasted it and it could not recognise as defined custom-Error in the contract.
Checking account access…