Last active
March 14, 2018 15:25
-
-
Save critesjosh/87f9ff1e432216fa6f6ef1b5551efbf2 to your computer and use it in GitHub Desktop.
How to correctly throw errors in Solidity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.0; | |
contract ThrowErrorExample { | |
bool isTrue = true; | |
uint num = 1; | |
//Bad code, do not emulate | |
function silentFail() public view returns (uint){ | |
if(isTrue != true){ | |
return num; | |
} | |
} | |
function throwsError() public view returns (uint){ | |
require(isTrue != true); | |
return num; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment