I was going through the Solidity Exception-Handling examples and I saw below example:

pragma solidity ^0.4.0;
contract VendingMachine {
function buy(uint amount) payable {
    if (amount > msg.value / 2 ether)
        revert("Not enough Ether provided.");
    // Alternative way to do it:
        amount <= msg.value / 2 ether,
        "Not enough Ether provided."
    // Perform the purchase.

I'm getting multiple errors when trying to execute it on Remix saying that the 2 arguments given expected 1. So, I want to know that Is this support is deprecated now or Do I have to use a specific solidity version?

link: Exception-handling example


I have seen proposals about introducing this functionality, but as yet, you can't pass a second string argument to require. You'll notice that the solidity version selected in the docs you have linked is "develop". I assume this is for functionality which is still in development.

If you go to the most recent version 0.4.21, you'll see that passing a second argument like this isn't allowed.

It would be nice if it were, as it would make debugging and error catching easier, but for now it can't be done.


Yes, as @AnAllergyToAnalogy pointed out, is a feature under development and its available only for the nightly version of Solidity (0.4.22)

You can actually try out it from remix but you need to select the compiler version 0.4.22-nightly from settings->Solidity version.

Then this code will work properly

pragma solidity ^0.4.21;

contract Sharer {
    function sendHalf() public payable {
        require(msg.value % 2 == 0, "Even value required.");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.