You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
652 B
29 lines
652 B
pragma solidity >=0.8.0 <0.9.0;
|
|
|
|
contract Test {
|
|
function op(uint y) external returns (uint){
|
|
uint a = 100;
|
|
uint b = 0;
|
|
|
|
if (y == 0)
|
|
return 0;
|
|
if (y == 1)
|
|
require(false, 'sorry');
|
|
if (y == 2)
|
|
uint x = (a / b);
|
|
if (y == 3)
|
|
revert();
|
|
}
|
|
|
|
function a(uint x) external returns (uint) {
|
|
try this.op(x) returns (uint v) {
|
|
return 0;
|
|
} catch Error(string memory /*reason*/) {
|
|
return 1;
|
|
} catch Panic(uint /*errorCode*/) {
|
|
return 2;
|
|
} catch (bytes memory /*lowLevelData*/) {
|
|
return 3;
|
|
}
|
|
}
|
|
}
|
|
|