Search code examples
ethereumsoliditysmartcontracts

Is there a way to return a function as false and still execute code untill it reverts, eq: function owner() { owner = 0x0; revert(); }


So putting revert() or throw at the end of the function simply prevents any code from executing, I am looking for a clever way to escape this be it with external call, delegatecall or anything, so:

function thiss()
{
owner = 0x0...;
throw; //gives error, no changes whatsoever - what I want is to see changes and then "throw"...
}

Solution

  • One way to do that is to use event. You can emit an event and then return the function. You can know the error by looking at logs field in the transaction receipt.

    event ErrorLog(string msg);
    
    function this() public {
        Owner = 0x583031D1113aD414F02576BD6afaBfb302140225;
        emit ErrorLog("Error in function this");
        return;
    }