I tried to run the following code to check the error message when the condition of require()
is not met.
pragma solidity ^0.5.16;
...
function addUser(string memory name) public returns (int) {
require(!userList[msg.sender].isSigned, "You already have an account.");
...
}
When the condition of require()
is met, it worked as expected, but when the condition wasn't met, I could always see the following error message:
transact to Messenger.addUser errored: gas required exceeds allowance (8946128) or always failing transaction
I thought that the problem was due to the gas limit of the block, so I increased the gas limit from ten thousand to one million. However, the problem was not solved and I don't know what the cause is.
What I want to ask is
- Does solidity always show that error message when the condition of
require()
is not met? - How to check the message("You already have an account.") I specified in
require()
?
Thanks for help :)
require()
?" - what does that mean? – goodvibration Jan 23 '20 at 6:52