Skip to main content
added 80 characters in body
Source Link
matank001
  • 820
  • 5
  • 16

Well, you can try to use try-catch

Currently, Solidity supports different kinds of catch blocks depending on the type of error. If the error was caused by revert("reasonString") or require(false, "reasonString") (or an internal error that causes such an exception), then the catch clause of the type catch Error(string memory reason) will be executed.

Inside the catch block return the value you desire like in this example:

try initialize() returns (uint v) {
        return true;
    } catch Error(string memory /*reason*/) {
        // This is executed in case
        // revert was called inside initialize
        // and a reason string was provided.
        
        return false;
}

Because initialize is payable, you need to call it in the correct way with funds

Well, you can try to use try-catch

Currently, Solidity supports different kinds of catch blocks depending on the type of error. If the error was caused by revert("reasonString") or require(false, "reasonString") (or an internal error that causes such an exception), then the catch clause of the type catch Error(string memory reason) will be executed.

Inside the catch block return the value you desire like in this example:

try initialize() returns (uint v) {
        return true;
    } catch Error(string memory /*reason*/) {
        // This is executed in case
        // revert was called inside initialize
        // and a reason string was provided.
        
        return false;
}

Well, you can try to use try-catch

Currently, Solidity supports different kinds of catch blocks depending on the type of error. If the error was caused by revert("reasonString") or require(false, "reasonString") (or an internal error that causes such an exception), then the catch clause of the type catch Error(string memory reason) will be executed.

Inside the catch block return the value you desire like in this example:

try initialize() returns (uint v) {
        return true;
    } catch Error(string memory /*reason*/) {
        // This is executed in case
        // revert was called inside initialize
        // and a reason string was provided.
        
        return false;
}

Because initialize is payable, you need to call it in the correct way with funds

Source Link
matank001
  • 820
  • 5
  • 16

Well, you can try to use try-catch

Currently, Solidity supports different kinds of catch blocks depending on the type of error. If the error was caused by revert("reasonString") or require(false, "reasonString") (or an internal error that causes such an exception), then the catch clause of the type catch Error(string memory reason) will be executed.

Inside the catch block return the value you desire like in this example:

try initialize() returns (uint v) {
        return true;
    } catch Error(string memory /*reason*/) {
        // This is executed in case
        // revert was called inside initialize
        // and a reason string was provided.
        
        return false;
}