Im learning Solidity. As far as I'm aware, it's recommended using "require" to handle errors. But, I'd like to inform the users about the kind of errors they make, e.g. an argument is invalid or out of range, etc.
Question: How to write a error message in error handling functions like "require"?
Also, I need to know if it makes sense to have such error messages in contract?
Best Answer
It is included since
Solidity 0.4.22
. There is a merged branch adding this feature in the milestone.The documentation states
In the past it was used like this
And in
Solidity 0.4.22
and newer it can be used like thisAdding the reason as the second parameter