-
Notifications
You must be signed in to change notification settings - Fork 1
/
Error's.sol
35 lines (29 loc) · 942 Bytes
/
Error's.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
pragma solidity ^0.8.3;
contract Error {
function testRequire(uint _i) public pure {
//require(_i > 0);
//-Inputs
//Conditions before execution
//Retunrs values from called other contract functions
require( _i > 0); "Input must be great than 10;)
}
function restRevert (uint _i) public pure {
//revert useful when the condition to check the complex
//this code does the same as the example above
if (i > 0) {
revert("Input must be great than 10;)");
}
}
uint public num;
function testRequire() public {
num = testRequire(10);
assert(num == 0);
}
error InsufficientBalance(uint balance, uint withdrawAmount);
function testCustomError(uint _withdrawAmount) public view {
uint bal = address(this).balance;
if (bal < _withdrawAmount) {
revert InsufficientBalance({balance: bal, withdrawAmount: _withdrawAmount});
}
}
}