Created
July 18, 2023 13:51
-
-
Save TehilaFavourite/21928d15d6ce92786af72a35d1572b3c to your computer and use it in GitHub Desktop.
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
// SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.0; | |
error CustomError(string message); | |
contract CustomErrorExample { | |
uint256 public maxValue = 100; | |
function setValue(uint256 newValue) public { | |
// Check if the input exceeds the maximum value allowed | |
if (newValue > maxValue) { | |
revert CustomError("Value exceeds the maximum allowed"); | |
} | |
// Set the new value | |
maxValue = newValue; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment